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

    result -1 in Iff statement

    I have a IFF statement that checks a check box is on/off. The result is always a "-1" How do I get it to be something else?



    IIf([Provincial Guest]=yes,1) Or IIf([District Guest]=Yes,2) Or IIf([Officers "G"]=Yes,3) Or IIf([Chairmen "G"]=Yes,4) Or IIf([Council "G"]=Yes,5) Or IIf([Zone Commader]=Yes,6)

    all the results are "-1"

    I also tried
    Guest2: IIf([Provincial Guest]=Yes,"A"); IIf([District Guest]=Yes,"B") and got a "-1"

    Guest2: IIf([Provincial Guest]=Yes,"A")or IIf([District Guest]=Yes,"B") and got a "-1"

    What am I doing wrong?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I take it only one of them will be "yes" at a time? You are trying to do a nested IIF statement, right?

  3. #3
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226
    Yes, only one will be yes,
    Nested iif ?? maybe.
    Trying to get the results into a single field.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    IIf([Provincial Guest]=True,1, IIf([District Guest]=True,2, IIf([Officers "G"]=True,3, IIf([Chairmen "G"]=True,4, IIf([Council "G"]=True,5, IIf([Zone Commader]=True,6,0))))))

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

    How big can I make this IFF?

    How big can I make this IFF?

    At present I have 13

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You can nest IIF's up to 7 levels.

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Since these are mutually exclusive settings, have you looked at the OptionControl?

  8. #8
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    For more that 7 tests, you could use the Switch() function. It would look like :

    Code:
    Switch([Provincial Guest]=True,1, [District Guest]=True,2, [Officers "G"]=True,3, [Chairmen "G"]=True,4, [Council "G"]=True,5, [Zone Commader]=True,6)
    I would put these in a lookup table:

    GuestID| Description
    --------------------------
    1|Provincial Guest
    2|District Guest
    3|Officers "G"
    4|Chairmen "G"
    5|Council "G"
    6|Zone Commader


    Then you can use a combo box, or list box to male a selection. Also, it is easier to add a new selection.

    BTW, you should only use letters, numbers and the underscore in field names........

  9. #9
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226
    WOW!! I will have to play with Switch function and look up tables.
    I have never used them or know how to and where to use them.

    I will give it a try this weekend.

    Thanks

  10. #10
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    One more thing..... You should only use letters, numbers and underscores in your object names. No one should see the field names, so quotes (as in Officers "G") or spaces really doesn't matter.

    Plus, some special characters are also delimiters (" ' # ). Using them in names will cause you headaches later on.

    Good luck

  11. #11
    newtoAccess is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    226
    Thanks, I have not had time to play<Learn> with switch().

    thanks

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

Similar Threads

  1. Evaluate result of sql query
    By Tyork in forum Programming
    Replies: 2
    Last Post: 11-09-2010, 05:41 PM
  2. can i put the result in array?
    By dada in forum Programming
    Replies: 1
    Last Post: 08-19-2010, 07:17 PM
  3. how to return the result?
    By lamkee in forum Access
    Replies: 1
    Last Post: 08-10-2010, 10:50 AM
  4. How do I determine a SQL query result?
    By Trainman in forum Database Design
    Replies: 1
    Last Post: 10-15-2009, 04:49 AM
  5. Multiple inputs one result
    By ee12csvt in forum Queries
    Replies: 0
    Last Post: 09-11-2009, 03:19 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