Multiple values in query criteria from one form combo box

ritco

Registered User.
Local time
Yesterday, 23:39
Joined
Apr 20, 2012
Messages
34
I have a combo box on a form that has only three values, ‘All’, ‘Pet’, or ‘Shoe’.


The logic I’m trying to achieve is as follows:

If selected branch = “Shoe” then Branch = “01”
If selected branch = “Pet” then Branch = “05”
If selected branch = “Both Shoe & Pet” then Branch = “01” or “05”

Here is my WHERE statement code from my query:

WHERE ((dbo_SalesHisItemPcVw.Branch)=IIf([Forms]![frmRollingDates]![cboBranch]="Shoe","01",IIf([Forms]![frmRollingDates]![cboBranch]="Pet","05","01" Or "05"))

The “Or” statement does not work.

“01” & “05” represent the alpha values of the branches in the table.
 
Try:
WHERE ((dbo_SalesHisItemPcVw.Branch)=IIf([Forms]![frmRollingDates]![cboBranch]="Shoe","01",IIf([Forms]![frmRollingDates]![cboBranch]="Pet","05","01 Or 05"))
 
Your solution looks like the exact code I posted. The "Or" operator does not work.

I did get it working though, with the following solution:

WHERE ((dbo_SalesHisItemPcVw.Branch)=
IIf([Forms]![frmRollingDates]![cboBranch]="01","01",IIf([Forms]![frmRollingDates]![cboBranch]="05","05",[dbo_SalesHisItemPcVw]![Branch]))
 

Users who are viewing this thread

Back
Top Bottom