Results 1 to 7 of 7
  1. #1
    Darla is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    May 2016
    Posts
    25

    function has the wrong number of arguments

    Hello, can anyone help me figure out what is wrong with my below code? I keep getting the "wrong number of arguments" error in this query

    Status: IIf([QStatus]= "Open" And [Type] ="Check In") Or ([QStatus] "Open" and [Type] ="Check Out"), Or [QStatus] ="Closed" and [Type] Is Null And [checkoutDateIn] is Null), "Checked Out"), IIf([QStatus] = "Closed" And [Type] Is Null And [checkoutDateIn] Is Not Null, "Checked In"))

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    extra paren needed at start

    IIf( ([QStatus]= "Open" And [Type] ="Check In") Or

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    extra paren needed at start, and extra comma

    IIf( ([QStatus]= "Open" And [Type] ="Check In") Or

    Status:
    IIf( ([QStatus]= "Open" And [Type] ="Check In") Or
    ([QStatus] "Open" and [Type] ="Check Out") Or
    ([QStatus] ="Closed" and [Type] Is Null And [checkoutDateIn] is Null), "Checked Out",

    IIf( ([QStatus] = "Closed" And [Type] Is Null And ([checkoutDateIn] is not null)), "Checked In")
    )

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    ??? Seems this part does not have a false condition

    Code:
    IIf([QStatus] = "Closed" And [Type] Is Null And [checkoutDateIn] Is Not Null, "Checked In")

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Two things, before trying to straighten out the hairball that frequently arises out of the use of nested IIF constructs:

    First, TYPE is a Reserved Word and shouldn't be used as the name of a Field, as doing so can cause all kinds of problems, perhaps (but not guaranteed) even a part of the problem here.

    Secondly, you're using VBA, here, and in VBA the correct syntax for

    [Type] Is Null

    would be

    IsNull([Type])

    Likewise

    [checkoutDateIn] Is Not Null

    would be

    Not IsNull([checkoutDateIn])

    and so forth.

    I'd start off by correcting these missteps and then see what you're left with.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Darla is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    May 2016
    Posts
    25
    Quote Originally Posted by Missinglinq View Post
    Two things, before trying to straighten out the hairball that frequently arises out of the use of nested IIF constructs:

    First, TYPE is a Reserved Word ...
    So I've changed it to this and I still get that same error... Do you think it is because I'm using Type as a field name? Or am I missing something else too? I appreciate the help!

    IIf(([QStatus]= "Open" And [Type]="Check In") Or [QStatus]="Open" and [Type]="Check Out"), Or [QStatus]="Closed" And IsNull([Type]) And IsNull([checkoutDateIn]),"Checked Out"),IIf([QStatus]="Closed" And IsNull([Type]) And Not IsNull([checkoutDateIn]),"Checked In","Checked Out"))

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,725
    Since you are having issues with a fairly complex iif, why not do some testing/analysis?

    General structure/syntax of IIF IIF (condition, result if true, result if false)
    Create a new Select query and start with a simple condition

    eg
    Code:
      IIf([QStatus]= "Open" ,"Open", "Not Open")
    then add new conditions 1 at a time and check your output

    then add another condition and check your output.

    Then review you complex iif, compare to your built up version that worked....

    Good luck

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

Similar Threads

  1. Replies: 3
    Last Post: 09-09-2015, 11:26 AM
  2. Replies: 3
    Last Post: 07-18-2015, 05:02 PM
  3. Iif function--- What am I doing wrong?
    By MaineLady in forum Access
    Replies: 17
    Last Post: 08-29-2014, 02:03 PM
  4. Replies: 3
    Last Post: 02-12-2014, 03:36 PM
  5. HELP - Invalid number of arguments
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 07-22-2010, 09:38 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