Results 1 to 4 of 4
  1. #1
    raweber is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    12

    Syntax for Use of Yes/No Field in a Select Statement

    I have a query that is supposed to set a value for the STATUS of the record as part of the query. That is, depending on the status of various check boxes and date fields the STATUS field of the query record changes (i.e. from "Study Phase" to "Awaiting Closeout" and several other phases).

    I'm not having any difficulties with the dates and use Null values effectively to drive the decision tree. It is when I tried to add in a Yes/No field that I can't get the syntax right. The field label is "IM" and here are a few of the things I've tried:



    Code:
    IIf(([IM])=-1,...)
    IIf(([IM])=False,...)
    The ellipsis marks the THEN/ELSE portion of the IIf statement. Basically, all I'm looking to do is incorporate the value of a check box into the decision tree.

    Anyone know how to do this properly?

    Thanks, Rob

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    If IM is truly a Yes/No field, it is stored as Boolean, so Yes=True and No=False.
    So, you should just be able to write it like:

    IIF([IM],what to return in IM is Yes,what to return if IM is No)

    If you are still having issues, post your entire equation here so we can see if there are any other issues with it.

  3. #3
    raweber is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    12
    Ahh, that was simple. Now if only there was something that helped you count the number of parentheses in these huge nested IIf statements to make debugging easier.

    Thanks!
    Rob

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are most welcome!

    If you have huge nested IIF statements, you may want to consider converting it to a User Defined Function (UDF) in VBA instead.
    They are much easier to maintain, and if you are using the formula in more than one place, you only have to update one function instead of all the formulas.

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

Similar Threads

  1. Replies: 13
    Last Post: 03-12-2015, 05:55 PM
  2. syntax for if then statement
    By crowegreg in forum Forms
    Replies: 3
    Last Post: 09-05-2013, 03:33 PM
  3. If statement syntax help!
    By Richie27 in forum Programming
    Replies: 15
    Last Post: 06-15-2012, 12:58 AM
  4. Replies: 7
    Last Post: 08-17-2011, 01:49 PM
  5. Select statement syntax?
    By ksmith in forum Programming
    Replies: 3
    Last Post: 06-24-2010, 09: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