IIF Statement with OR

streamsleek

New member
Local time
Today, 06:23
Joined
Feb 26, 2013
Messages
3
I have a situation where a user would like to pull two department types in a query. I previously had the criteria defined by a form field. So if "warehouse-bulk" is selected on the form, it will pull the records for "warehouse-bulk, and 'warehouse-retail". I have attempted this with the below statement, but it doesn't like it.

Old
[forms]![dateselect]![dept]

New
IIf([Forms]![dateselect]![dept]="Warehouse-Bulk","Warehouse-Bulk" OR "Warehouse-Retail",[forms]![dateselect]![dept])
 
You have to repeat the field:

Field = "ABC" OR Field = "DEF"
 
I changed it to

IIf([Forms]![dateselect]![dept]="Warehouse-Bulk",([Errors].[Department])="Warehouse-Bulk" Or ([Errors].[Department])="Warehouse-Retail",[forms]![dateselect]![dept])

And now i am getting a message stating " This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables"
 
the 2nd parameter is not the criteria you have to write like this:

Code:
IIf([Forms]![dateselect]![dept]="Warehouse-Bulk" OR  [Forms]![dateselect]![dept]="Warehouse-Retail",Value if yes ,[value if not] [forms]![dateselect]![dept])
 
I am not the greatest at explaining things, and I think i may have confused everyone. the user will select the department "warehouse-bulk" from the list on the form (about 6 departments total). Then the query will include records from departments "warehouse-bulk", and "warehouse-retail".

Looking at the posted code, i think i might have lead you to believe the opposite
 
I misunderstood you, though in retrospect you explained it fine. Unfortunately, I've never tried to use IIf() functions in a query criteria. I'd be more likely to use this method:

http://www.baldyweb.com/wherecondition.htm

and adjust it for that particular choice.
 

Users who are viewing this thread

Back
Top Bottom