Microsoft Access Help

Associate
Joined
29 Jul 2005
Posts
445
Location
Matlock
Hi there,

I am trying to write an IIF expression in a query in access so far i have got:
Code:
Expr1: IIf([Marc],"Marc",IIf([Andy],"Andy",IIf([Marc] & [Andy],"Both","")))
I know this is not correct as this never shows the word "Both". The Fields [Marc] and [Andy] are both yes/no feild. I'm guessing i've messed up here:
Code:
IIf([Marc] & [Andy],
Would be grateful if someone could point me in the right direction

thanks in advance

Marc
 
Try
Code:
IIF(AND([Marc],[Andy]),

The & symbol is used to join strings together.
 
Last edited:
Thanks for your reply but if i type in that code it says:

The expression you enetered contains invalid syntax.

You may have entered a comma without a preceding value or identifier

I'm not too sure what this is saying, any more help would be very appreciative

thanks again

Marc
 
Right, try this, Ive tested it and it works
Code:
Expr1: IIf([Marc],"Marc",IIf([Andy],"Andy",IIf(([Marc] AND [Andy]),"Both","")))
 
You need to do the AND test first. "Both" will never show doing it in your original order because for the [Marc] AND [Andy] to evaluate to TRUE the first IIf test must also evaluate to TRUE stopping the test ever getting to the AND test. (Sorry not very well explained :p)

Try

IIf([Marc] AND [Andy],"Both",IIf([Marc],"Marc",IIf([Andy],"Andy","Neither")))
 
Fezzer said:
You need to do the AND test first. "Both" will never show doing it in your original order because for the [Marc] AND [Andy] to evaluate to TRUE the first IIf test must also evaluate to TRUE stopping the test ever getting to the AND test. (Sorry not very well explained :p)..................

Good thinking batman :D
 
Last edited:
Back
Top Bottom