If Statement

houseofturner

Registered User.
Local time
Today, 23:10
Joined
Dec 10, 2009
Messages
37
If I put an Iff statement into a Query such as:

IIf([Table A]![FieldName] Like "A" Or [Table A]![FieldName] Like "B","Answer A", "Answer B")

It works ok but as the table name is the same why do I have to repeat it. If I try:

IIf([Table A]![FieldName] Like "A" Or Like "B","Answer A", "Answer B")

It does not seem to evaluate correctly.

This means that multiple "Or" criteria referencing the same field results in very long queries. I know you dont need to in VBA but I am doing this in a query grid.
 
Because OR and AND are operators requiring TWO operands, where each operand is a logical expression that can come out as TRUE or FALSE.

Update:
For multiple choices segregated by OR , you can instead use the IN ("choice1", "choice2",.... "ChoiceN"). Look up the IN keyword in the documentation of Access SQL
 
Last edited:
So is there any way of having multiple criteria referencing the same field without repeating the field name each time?
 

Users who are viewing this thread

Back
Top Bottom