Results 1 to 3 of 3
  1. #1
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410

    Complex IIf statement?

    Could someone help me with this IIf statment?



    See if this is the correct way to get the results for:


    Code:
    ProgramStatus: IIf([StatusID]<>3,"Inactive",IIf([StatusID]=3 And ([ProgramStatusID]=3),"Active","Active 0 Mbrshp"))
    1. Active - StatusID =3 and ProgramStatusID = 3
    2. Active w/ 0 mbs - StatusID = 3 and ProgramStatusID <> 3 or IsNull
    3. Inactive - StatusID <> 3

    it doesn't seem right.

    I get this:

    Code:
    OrgTypeID    OrgType    ProgramStatus    NoOfMbrshp
    2            Basic Skills Program    Active          642
    2            Basic Skills Program    Active 0 Mbrshp    82
    2            Basic Skills Program    Inactive          509
    because when I remove the first part of the IIf I get this:
    Code:
    OrgTypeID    OrgType    ProgramStatus    NoOfMbrshp
    2           Basic Skills Program    Active    642
    2           Basic Skills Program    Active 0 Mbrshp    591

    There are these codes:
    StatusID contains 1 and 3
    ProgramStatusID contains Nulls, 1, and 3

    Where 3 means Active

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

    ProgramStatus: IIf([StatusID]=3, IIf([ProgramStatusID]=3, "Active", "Active 0 Mbrshp"), "Inactive")
    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.

  3. #3
    aellistechsupport is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Apr 2014
    Posts
    410
    Thank you!
    I had this:
    Code:
    ProgramStatus: IIf([StatusID]=3 And [ProgramStatusID]=3,"Active",IIf([StatusID]=3 And IsNull([ProgramStatusID] Or [ProgramStatusID]<>3),"Active 0 Mbrshp","Inactive"))
    and tried yours and got the same results.
    Yours is cleaner.

    thank you!

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

Similar Threads

  1. 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
  2. IIF statement too complex, table instead?
    By Lauren1989 in forum Queries
    Replies: 3
    Last Post: 01-25-2012, 01:27 PM
  3. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  4. Complex IIF Statement
    By ksamaniego in forum Queries
    Replies: 3
    Last Post: 08-11-2011, 09:09 AM
  5. Replies: 2
    Last Post: 08-26-2009, 10:43 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