IF or IFF function

J

JoLeigh

I would like to use IF/Then logic in the design view of the query, but can't
quite seem to make it work. For example:
Expr1:if([field name]=4, "yes","no")

Would appreciate someone setting me straight on this.
 
T

Tom Lake

JoLeigh said:
I would like to use IF/Then logic in the design view of the query, but
can't
quite seem to make it work. For example:
Expr1:if([field name]=4, "yes","no")

Would appreciate someone setting me straight on this.

You're missing an I

Expr1:IIf([field name]=4, "yes","no")

should work if [field name] is a defined numeric field.

Tom Lake
 
K

Klatuu

The If Then Else construct will not work with queries. You will have to use
the Iif.
The Iif construct can be hard to read nested to two levels or more can get
really hard to read. Your alternative is to use a user defined function to
get what you need.
 
J

JoLeigh

Thanks much! That missing "I" you discovered just made my life a lot simpler!

Tom Lake said:
JoLeigh said:
I would like to use IF/Then logic in the design view of the query, but
can't
quite seem to make it work. For example:
Expr1:if([field name]=4, "yes","no")

Would appreciate someone setting me straight on this.

You're missing an I

Expr1:IIf([field name]=4, "yes","no")

should work if [field name] is a defined numeric field.

Tom Lake
 
D

Duane Hookom

I would simply use
Expr1:[Field Name]=4
This will return True/-1 or False/0 which can easily be displayed as Yes or
No in a text box.
 
Top