IIF in Select Query

J

jrizzo77

Trying to use the IIF expression in conjunction with a combo box in a
form.

Combo Box:
Blue
Red
Green
Blue/Red

In the query I want the results to filter the Color (obviously). For
the specific colors it works fine but for the combination of colors I
can't get it to work.

iif([color]="Blue","blue",iif([color]="Blue/Red","Blue" Or "Red"))

I get the error "the expression is incorrect or to complex"

I have tried various combination's of Like and IN and I can't get
anything to work

Any help would be appreciated.
 
J

John W. Vinson

Trying to use the IIF expression in conjunction with a combo box in a
form.

Combo Box:
Blue
Red
Green
Blue/Red

In the query I want the results to filter the Color (obviously). For
the specific colors it works fine but for the combination of colors I
can't get it to work.

iif([color]="Blue","blue",iif([color]="Blue/Red","Blue" Or "Red"))

I get the error "the expression is incorrect or to complex"

I have tried various combination's of Like and IN and I can't get
anything to work

Any help would be appreciated.

You can't pass operators such as OR with a parameter.

I'd suggest

[Color] = [Forms]![YourForm]![comboboxname] OR
([Forms]![YourForm]![comboboxname] = "Blue/Red" AND [Color] IN ("Blue", "Red")
 
J

jrizzo77

Trying to use the IIF expression in conjunction with a combo box in a
form.
Combo Box:
Blue
Red
Green
Blue/Red
In the query I want the results to filter the Color (obviously).  For
the specific colors it works fine but for the combination of colors I
can't get it to work.
iif([color]="Blue","blue",iif([color]="Blue/Red","Blue" Or "Red"))
I get the error "the expression is incorrect or to complex"
I have tried various combination's of Like and IN and I can't get
anything to work
Any help would be appreciated.

You can't pass operators such as OR with a parameter.

I'd suggest

[Color] = [Forms]![YourForm]![comboboxname] OR
([Forms]![YourForm]![comboboxname] = "Blue/Red" AND [Color] IN ("Blue","Red")

thanks. that works perfect!
 

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