more on iif statement question- need to add to criteria of query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • buddyr
    New Member
    • Apr 2007
    • 105

    more on iif statement question- need to add to criteria of query

    example:
    field1 bblandscape, wallmart, kmart
    field2 4,6,9
    field3 5,7,6
    field4 12,0,5
    field5

    if field2 > field3 then field5 = "Yes"
    if field4 = 0 then field5 = "Yes"

    can I add an if (iif) statement or switch statement to field5 in design view of a query and perform both these conditional statements together in some way. I am not writing the syntax right.
    thank you

    **** I RECIEVED THIS SOLUTION****
    Try

    field5: iif(field4 = 0, "Yes", iif(field2 > field3, "Yes", "No")

    Now I want to be able to run the query and only show the records with "YES" in field5. I usually would put YES under field5 in criteria box in design view.
    But its not working.
    any ideas
    Thank you
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    How about this
    [code=sql]
    field5: iif(field4 = 0 or field2 > field3, "Yes","No")

    [/code]

    Comment

    • buddyr
      New Member
      • Apr 2007
      • 105

      #3
      thank you it works in my example.
      Now I will take it to my database

      Comment

      Working...