OR statement in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apank
    New Member
    • Sep 2008
    • 31

    OR statement in Access

    Is there a way to the an OR statement when doing "If, than" statements in Access. I know how to do it in Excel, but can't seem to do in in Access.

    Example: iff ([a] or [b] >1,"Yes", "No")


    Thank you for any direction you can provide.

    A
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi. Each condition that is being ORd has to be set out in full. You cannot shortcircuit this by leaving the condition to the end. The Access in-line IIF statement nearest to what you ask would be:

    Code:
    IIF(([a] > 1) OR ([b] > 1), "Yes", "No")
    The OR in this case is an operator, like any other operator such as + or -. It is applied in the normal way: [expression] OR [expression].

    The OR in Excel is a function, not an operator. It is applied like this:

    OR ([expression], [expression])

    The Excel equivalent of the in-line if (or iif for short) statement above still requires that the conditions are set out in full:

    Code:
    =IF(OR(A1 > 1, B1 > 1), "Yes", "No")
    but this cannot be used in Access; use the IIF version listed above instead.

    -Stewart

    Comment

    • apank
      New Member
      • Sep 2008
      • 31

      #3
      Excellent.

      Thank you very much.

      Comment

      Working...