Results 1 to 3 of 3
  1. #1
    bburton is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    15

    What is wrong with this IFF?

    I'm trying to produce a multiple IIf argument. With so much coding in it, I've confused myself. I'm still working on trying to figure it out, but if any of you could figure it out before I do that'd be great. I have 8 possible outcomes from check box results. Only one outcome can be produced into the proper string. Otherwise if nothing is selected, then it'd just be an empty space/null. It is from a unbound Form.

    Outcomes:

    Missing Window & Missing Door -> Missing window and door.
    Non-Op Window & Non-Op Door -> Non-Op window and door.
    Non-Op Window & Missing Door -> Non-Op window and missing door.
    Missing Window & Non-Op Door -> Missing Window and non-op door.
    Missing Window -> Missing window.
    Missing Door -> Missing door.
    Non-Op Window -> Non-op window.


    Non-Op Door -> Non-op door.
    Nothing selected -> Null

    My latest attempt was:


    Code:
    IIf([Forms]![Checklist]![RSwNO]  And [Forms]![Checklist]![RDrNO],"The rear window switches and door  handles are  non-operational",IIf([Forms]![Checklist]![RSwNO]<>0,"The rear  window switches are non-operational. ") &  IIf([Forms]![Checklist]![RDrNO]<>0,"The rear door handles are  non-operational.")) & IIf([Forms]![Checklist]![RSwMiss] And  [Forms]![Checklist]![RDrMiss],"The rear window switches and the door  handles are missing. ",IIf([Forms]![Checklist]![RSwMiss]<>0,"The  rear window switches are missing. ") &  IIf([Forms]![Checklist]![RDrMiss]<>0,"The rear door handles are  missing.")) & IIf([Forms]![Checklist]![RDrNO] And  [Forms]![Checklist]![RSwMiss],"The rear window switches are missing and  the door handles are non-operational.  ",IIf([Forms]![Checklist]![RDrMiss] And [Forms]![Checklist]![RSwNO],"The  rear window switches are non-operational and the door handles are  missing. ",""))
    That nearly worked, however... It would produce some duplicates when one non-op is checked and one missing is checked. Such as:

    "The rear door handles are non-operational.The rear window switches are missing. The rear window switches are missing and the door handles are non-operational."

    When it should be just "The rear window switches are missing and the door handles are non-operational."

    I hope I didn't make this too confusing, I've confused myself with this so many times....

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This is what I did. Type an immediate IF() statement.

    Code:
    iif(Condition,"Text",False)
    Then, where ever there is a FALSE, paste the IF() statement again, for a total of 8 times.

    (this is 4 times)
    Code:
    iif(Condition,"Text",iif(Condition,"Text",iif(Condition,"Text",iif(Condition,"Text",False))))
    Next, where ever there is the word "Condition", replace it with your test:

    Code:
    iif([Forms]![Checklist]![RSwNO]  And [Forms]![Checklist]![RDrNO],"Text",iif(Condition,"Text",iif(Condition,"Text",iif(Condition,"Text",False))))
    And replace "Text" with your text:

    Code:
    iif([Forms]![Checklist]![RSwNO]  And  [Forms]![Checklist]![RDrNO],"The rear window switches and door  handles are  non-operational",iif(Condition,"Text",iif(Condition,"Text",iif(Condition,"Text",False))))
    Do this for each of the 8 nested IIF() statements.


    --------------------------------------
    This is my attempt:

    Code:
     x = IIf([Forms]![Checklist]![RSwNO] And [Forms]![Checklist]![RDrNO], "The rear window switches and door handles are non-operational", IIf([Forms]![Checklist]![RSwMiss] And [Forms]![Checklist]![RDrMiss], "The rear window switches and the door handles are missing.", IIf([Forms]![Checklist]![RDrNO] And [Forms]![Checklist]![RSwMiss], "The rear window switches are missing and the door handles are non-operational.", IIf([Forms]![Checklist]![RDrMiss] And [Forms]![Checklist]![RSwNO], "The  rear window switches are non-operational and the door handles are missing. ", IIf([Forms]![Checklist]![RSwNO] <> 0, "The rear window switches are non-operational.", IIf([Forms]![Checklist]![RDrNO] <> 0, "The rear door handles are non-operational.", IIf([Forms]![Checklist]![RSwMiss] <> 0, "The rear window switches are missing.", IIf([Forms]![Checklist]![RDrMiss] <> 0, "The rear door handles are missing.", ""))))))))

  3. #3
    bburton is offline Novice
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    15
    Thanks a lot, I knew I must have done something wrong... That works great! Also thanks for the little step by step, that made it clear and easier for me to build a nested IIF (properly) lol.

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

Similar Threads

  1. What's wrong with this filter?
    By jgelpi16 in forum Queries
    Replies: 4
    Last Post: 02-21-2011, 12:58 PM
  2. Replies: 6
    Last Post: 10-12-2010, 09:35 AM
  3. What's wrong with this query?
    By jsoldi in forum Queries
    Replies: 2
    Last Post: 10-11-2010, 07:45 AM
  4. What's wrong with this expression
    By tallroger in forum Access
    Replies: 1
    Last Post: 05-05-2009, 04:00 PM
  5. What am I doing wrong?
    By brandon in forum Access
    Replies: 2
    Last Post: 08-03-2008, 10:26 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