IIF statment in query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am beating my self up here

I have a combo box with all the part numbers in it. I have a query that should select all request records if the combo is blank (IE nothign has been selected yet) or should limit the query to a specific part number if one is selcted. I have been tryin an IIF in the criteria, it works when a record is selected but complains the string is invalid when the combo is empty. Any help? Here is what i have in the criteria for part_number

IIf(IsNull([Forms]![mainJunk]![Combo0]),Like "*",[Forms]![mainJunk]![Combo0]

It doesnt like the "Like "*" ".. I have tried double single quotes, escape characters, no quotes.. grrrr..

Anyone know how to solve this

Thank

Chri
 
Try:

[Forms]![mainJunk]![Combo0] Or ([Forms]![mainJunk]![Combo0] Is Null)

When Combo0 has a value, the left side is active and only Records with
YourField = Combo0 are selected. When Combo0 is null, the right side is
true and therefore all Records are selected (anything OR True = True).

--
HTH
Van T. Dinh
MVP (Access)



Chichi said:
I am beating my self up here:

I have a combo box with all the part numbers in it. I have a query that
should select all request records if the combo is blank (IE nothign has been
selected yet) or should limit the query to a specific part number if one is
selcted. I have been tryin an IIF in the criteria, it works when a record is
selected but complains the string is invalid when the combo is empty. Any
help? Here is what i have in the criteria for part_number:
IIf(IsNull([Forms]![mainJunk]![Combo0]),Like "*",[Forms]![mainJunk]![Combo0])

It doesnt like the "Like "*" ".. I have tried double single quotes, escape
characters, no quotes.. grrrr..
 
Back
Top