Results 1 to 4 of 4
  1. #1
    sdc1234 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2013
    Posts
    89

    Expression u entered has a function containing the wrong number of arguments

    Here is code that keeps on giving me the same error msg Expression u entered has a function containing the wrong number of arguments can anyone help figure out whats wrong with this code




    test: IIf([EMI_Courses_ALL]![Location]="CANCELLED",IIf([Emi_Course_All]![Off Campus Beds]=IsNull(IIf([EMI_Courses_ALL]![Type]="E",1200,1800)*([EMI_Courses_ALL]![Students Scheduled]+[EMI_Courses_ALL]![Instructors]),([EMI_Courses_ALL]![Students Scheduled]+[EMI_Courses_ALL]![Instructors]-[EMI_Courses_ALL]![Off Campus Beds])*1200+[EMI_Courses_ALL]![Off Campus Beds]*1800),0)

    v/r
    novice

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Which part of the error message is confusing?

    error msg Expression u entered has a function containing the wrong number of arguments
    Did you look up the IIF() syntax and examples on Google? What part is confusing?

    If() or This one

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Simplify for readability. The table name is not need if the field names are not duplicated in the query. Follow the parens and commas. Parens must be in pairs. Since there are 11 parens, one is missing.

    test: IIf([Location]="CANCELLED", IIf([Off Campus Beds]=IsNull(IIf([Type]="E",1200,1800)*([Students Scheduled]+[Instructors])), ([Students Scheduled]+[Instructors]-[Off Campus Beds])*1200+[Off Campus Beds]*1800, something),0)

    That expression says:

    If Location = cancelled then if OffCampusBeds Is Null then this calc else something, otherwise Location <> cancelled and return 0

    I have no idea if the new paren is correctly placed for what you want.

    Possibly you really want Nz instead of IsNull.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Xipooo's Avatar
    Xipooo is offline Sr. Database Developer
    Windows 8 Access 2013
    Join Date
    Jan 2014
    Location
    Arizona
    Posts
    332
    This is the proper way to use an IIF statement.

    IIF(countNestedIIFs(currentProcess) > 1, refactorApplication = True, refactorApplication = False)

    Notice the first parameter returns a boolean value of true or false. When the parameter returns as true then the code in the second parameter is returned. If the first parameter returns a value of false then the third parameter is returned.

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

Similar Threads

  1. Replies: 6
    Last Post: 01-24-2013, 10:02 PM
  2. What's wrong with this expression in a query?
    By djclntn in forum Queries
    Replies: 18
    Last Post: 11-17-2011, 06:12 PM
  3. Expression gives wrong results
    By newtoAccess in forum Queries
    Replies: 22
    Last Post: 12-03-2010, 12:21 AM
  4. HELP - Invalid number of arguments
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 07-22-2010, 09:38 AM
  5. What's wrong with this expression
    By tallroger in forum Access
    Replies: 1
    Last Post: 05-05-2009, 04:00 PM

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