Results 1 to 7 of 7
  1. #1
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65

    iif Statement Help


    Is it possible to use an iif statement in a query iff= [STAT_CODE] =30 then say putaway and iff [STAT_CODE]= 50 then say allocated and iff [STAT_CODE]= 40 then say not allocated.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    That is nesting IIF's and perfectly legal up to 7 levels. Have you tried it yet?

  3. #3
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    I havent, How would you write that?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    What do you want returned if the [STAT_CODE] is not equal to 30, 40 or 50? Is the [STAT_CODE] field Numeric or Text?

  5. #5
    smc678 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    65
    Null, and its a number in the table

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So you have a Numeric field that contains a Null until you put something in it?

    Will the [STAT_CODE] field ever have a value other than 30, 40, 50 or Null?
    Last edited by June7; 07-01-2013 at 05:12 PM.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,641
    Try:

    IIf([STAT_CODE]=50, "allocated", IIf [STAT_CODE]=40, "not allocated", "unknown"))
    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.

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

Similar Threads

  1. Need help with a Like statement
    By itm in forum Queries
    Replies: 3
    Last Post: 10-22-2012, 12:55 PM
  2. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  3. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  4. Help on an IIF statement
    By Madmax in forum Access
    Replies: 4
    Last Post: 06-23-2011, 12:02 PM
  5. SQL like statement?
    By Cojack in forum Queries
    Replies: 4
    Last Post: 09-21-2010, 04:45 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