Results 1 to 2 of 2
  1. #1
    DHavokD is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    31

    Incorrect / Too Complex Error? [String comparison]

    Basically I am trying to make a query that will count the number of employees on a given project (Access 2003 / Win XP). The given project is the Project text box on a report (fed by another query).



    So the issue I am having is that each employee has upto 4 projects, so I need to say if any of their 4 projects = the project on the report, then keep them.

    I first tried it with a brutal IIF statement, said too complex. Then wrote it in VBA, says too complex.

    Code is:

    Function ProjectCompare(p1 As String, p2 As String, p3 As String, p4 As String, pr As String) As Boolean
    If ((p1 = pr) Or (p2 = pr) Or (p3 = pr) Or (p4 = pr)) Then
    ProjectCompare = True
    Else
    ProjectCompare = False
    End If

    End Function

    Any suggestions on making this work?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Do I understand you to say that the function you posted is being rejected by the compiler as "Too Complex"?

    How about something like:
    Code:
    Function ProjectCompare(p1 As String, _
                            p2 As String, _
                            p3 As String, _
                            p4 As String, _
                            pr As String) As Boolean
       Select Case pr
       
          Case p1
             ProjectCompare = True
          Case p2
             ProjectCompare = True
          Case p3
             ProjectCompare = True
          Case p4
             ProjectCompare = True
          Case Else
             ProjectCompare = False
       End Select
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Time Comparison
    By Larry819 in forum Queries
    Replies: 1
    Last Post: 06-22-2009, 09:26 PM
  2. Aligning a string vertically
    By Divardo in forum Queries
    Replies: 3
    Last Post: 06-10-2009, 11:19 AM
  3. order by - string and numeric
    By pen in forum Queries
    Replies: 10
    Last Post: 05-20-2009, 06:29 AM
  4. # added to string with Dlookup
    By normever in forum Programming
    Replies: 1
    Last Post: 02-27-2009, 10:52 AM
  5. Complex Date Comm/Amt Formula
    By JLongo in forum Programming
    Replies: 0
    Last Post: 11-21-2008, 10:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums