Nested Queries Help

G

Guest

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!
 
G

Guest

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"))))
 

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

Top