Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Testing IIF statement

    I am trying to test if either of 2 Yes/No fields are yes then [TotalRoom], else zero

    IIf([TaxableCode]=-1 or IIf([TaxableCode3]=-1,[TotalRoom],0))

    I get a message that there are wrong # of arguments. Any help with the syntax would be appreciated.

  2. #2
    Star Lounger
    Join Date
    Dec 2009
    Location
    Midwest, USA
    Posts
    79
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Try this: IIF([TaxableCode]=1,[TotalRoom], ( IIF([TaxableCode3]=1, [TotalRoom],0)))

    Use the second IIF statement as the result if the first IIF statement returns null. Then it cycles through your two fields in order to get your result. In Access the number of imbedded IIF statements is more limited than in Excel, but I know you can do a few if you need to check more fields.
    Last edited by caveman144; 2013-07-23 at 16:27.

  3. #3
    Star Lounger
    Join Date
    Dec 2009
    Location
    Midwest, USA
    Posts
    79
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Here is a link to Microsoft's explanation of the IIF statement: http://office.microsoft.com/en-us/ac...001228853.aspx

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,497
    Thanks
    3
    Thanked 42 Times in 42 Posts
    Another way to approach that is to add the two Yes/No fields together and if the result is other than 0, then you know at least one of them is checked. Nested IIF statements can get very complex, and difficult to debug, so if an alternate approach works it is often the best choice.
    Wendell

  5. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    6,183
    Thanks
    201
    Thanked 781 Times in 715 Posts
    Tom,

    The correct syntax is:
    Recall: IIf([Cases]![Case]=888 Or [Cases]![Case]=777,"Yes","No")
    Query Design
    QryDesign IIF-OR.JPG
    Query Result
    QryView IIF-OR.JPG

    HTH
    May the Forces of good computing be with you!

    RG

    VBA Rules!

    My Systems: Desktop Specs
    Laptop Specs


  6. #6
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank for everyone's input.


    Tom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •