Nested Queries Help

D

DyingIsis

Hello -

I have a single field and wish to create a query which categorizes the items
in the field. So if within the field, there is "AA', then return "Apples, if
not, look for "BB", if so then return "Balls", if not...

Below is the code:
Items: IIf(InStr(
![Field],"AA")>0,"Apples",IIf(InStr(
![
Field],"BB")>0,"Balls", IIf(InStr(
![ Field],"CC")>0,"Cats",
IIf(InStr(
![ Field],"DD")>0,"Dogs","Don’t Know"))))

For some reason, if it does not see "AA", I am only getting "Don't Know". It
does not seem to read the other if statements.

Please please help!
 
O

Ofer Cohen

In all other cases you have a space before " Field" name, try

Items:
IIf(InStr(
![Field],"AA")>0,"Apples",IIf(InStr(
![Field],"BB")>0,"Balls", IIf(InStr(
![Field],"CC")>0,"Cats",
IIf(InStr(
![Field],"DD")>0,"Dogs","Don’t Know"))))
 
Top