IIF Statement with an Or

dgaller

Registered User.
Local time
Yesterday, 23:53
Joined
Oct 31, 2007
Messages
60
I am trying to filter a query by a combo box. I put the below in the Criteria under my visible column in my query.

IIF([Combo141]=1,"Both" or "daily task","project")
 
What exactly are you trying to do with it?

As it stands, it appears to say
If the value in Combo141 is 1, then "Both" or "Daily Task", otherwise "project".
I could be missing something, but that doesn't make sense to me? How can you set the value of something to A or B?
 
What determines whether it's "both" or "daily task"?

Bob
 
I combo 141 = 1 Then then filter Visible for Both Or Daily Task. The next part will be if Combo141 =2 then Visible can = Both or Project.
 
I am not sure of how you are implementing this but since you are trying to pass a phrase: "Both" or "Daily Task" then I would guess that the quote are being dropped and your criteria is probably ending up looking like "Both or Daily Task".

I've ran into a similar situation once and the only way I worked around it was using a variable. Let's call it sVariable. If memory serves me correctly, I used double quotes to store the quotes in the variable. So it might look something like ...

sVariable = IIF([Combo141]=1,"""Both"" or ""Daily Task""","project")

Again, this caused me much frustration at the time because I probably did 30 steps to get it to work and there is probably is a quicker and cleaner way. I wouldn't trust my memory that much (I don't have a copy of the db anymore to check) but I do know there is an issue if you refer to a form control from the QBE and you want the quotes to pass with it.

-dK
 

Users who are viewing this thread

Back
Top Bottom