Results 1 to 4 of 4
  1. #1
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226

    multiple IF Statement

    How do I do a multiple if statement in a query?
    eg iif(fieldname=1,1,);iif(samefieldname=2,2,);iif(sa mefieldname=3,3,); up to 5

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    I prefer a User Defined Function (UDF) to nested IIF's. Much easier to read, understand and most importantly maintain.

  3. #3
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    iif(fieldname=1,1,(iif(samefieldname=2,2,(iif(same fieldname=3,3,)))))

    like RG I don't like nested beyond a couple levels if the logic is complicated - but will instead spread/break them apart in separate calculated fields in the query; and then tie them together with another calculated field. The advantage of this approach is one gets to visually inspect the intermediate logic results....

  4. #4
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226
    Great Thanks

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

Similar Threads

  1. iif statement with multiple conditions
    By ragsgold in forum Queries
    Replies: 7
    Last Post: 08-24-2011, 05:38 PM
  2. Replies: 2
    Last Post: 05-25-2010, 02:45 PM
  3. Replies: 5
    Last Post: 12-10-2009, 10:33 PM
  4. Replies: 1
    Last Post: 12-10-2009, 08:41 PM
  5. multiple iif statement NEED HELP PLZ
    By scott munkirs in forum Reports
    Replies: 1
    Last Post: 09-27-2006, 05:21 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