If Statement in Query Expression

music_al

Registered User.
Local time
Today, 09:09
Joined
Nov 23, 2007
Messages
200
Hi

I need to construct this type of IF Statement in a query, but Im not sure how to...

If [THIS_FIELD] = "This_Value" Then "Return_This"

Ive tried a few syntax combinations but nothing seems to work. Can anyone help ?

Thanks


Allan
 
You cant use an If...Then statement in a query. You have to use an IIF.

ie
Alias: iif([Expression]="YourValue",[DoIfTrue],[DoIfFalse])
 
Just a quick question for scooter - i understand IF's, well a bit but what is the difference between an IF and an IIF?
 
IIF a function where IF is a multiline procedure.
I believe it stands for Immediate IF.

Both have the same basic structure. If Then Else
Really IFF is little different from having made a simple IF procedure in a VBA standard module and named it as a function with three arguments.
 
One thing to consider when using immediate if's is that both the true and fale statement is tested to check where the logic/syntax is correct and working BEFORE the evaluation takes place, therefore they tend to take longer to process. This is especially relevant if you use nested iif's

Answer = Iff(Question1,True,Iff(Question2,True,False))

In the above example Access will first process Question1 then question2 then decide which one is correct and return the appropriate answer.

David
 

Users who are viewing this thread

Back
Top Bottom