IF or IFF function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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.
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top