IIF statment in query

C

Chichi

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
 
V

Van T. Dinh

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..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top