IIF in criteria giving error

Pyro

Too busy to comment
Local time
Tomorrow, 10:04
Joined
Apr 2, 2009
Messages
127
I am running a query based on a form selection.

If the form selection is a certain value, i want the query criteria to have multiple values:

Code:
[FONT=Calibri][SIZE=3]IIf([Forms]![FormName]![ComboName]="1",In ("1","2"),[Forms]![FormName]![ComboName])[/SIZE][/FONT]
This is throwing me a too complex to evaluate error. However if i set the query criteria to just In("1","2") everything works fine.

The field is being evaluated is a text string.

Any ideas?
 
Also "1" or "2" throws me the same error.
 
Code:
IIf([Forms]![FormName]![ComboName]="1",[COLOR=Red][B]In ("1","2")[/B][/COLOR],[Forms]![FormName]![ComboName])
An IIF statement returns a value, it will not return another statement or function or predicate. Also, if all you're checking against is 1 why not just return 1 in the FALSE part of the IIF statement?
 
Thanks vbaInet. The values i used were only used as an example.

The query i am putting together lumps some related items together for analysis. I got around the issue by creating an invisible textbox on my dialog form. In the After Update event of my combo, i update the text box with the second value where necessary, and then the query criteria is simply In(combo, textbox) which works fine.
 

Users who are viewing this thread

Back
Top Bottom