View Single Post
  #2  
Old July 10th, 2008, 05:03 AM posted to microsoft.public.access.queries
Allen Browne
external usenet poster
 
Posts: 11,706
Default Conditional IIF question/null value

Switch your query to SQL View (View menu.)
Locate the WHERE clause.
Change it to look like this:
WHERE IIf([Forms]![FRM_000_GET_MARKET]![Combo13]='ALL', True,
[YourFieldNameHere] = [Forms]![FRM_000_GET_MARKET]![Combo13])

Explanation:
You can't just drop this into the Criteria row in query design, because the
criterion would then be applied against a particular field. The expression
above is designed to return TRUE if the combo contains 'All'. True is true
for all records, and so all records meet this WHERE condition. If the combo
value is not 'All', then the field is compared against the combo, so only
the matching records are returned.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kerry" wrote in message
...
Hi! I've got a combo list in a form which I have the choices of multiple
numbers and an ALL choice (21, 22, 23, 24, ALL). I'm trying to use an IIF
statement in a query to either pull in the selected number to a criteria
or
leave the criteria blank in the case of ALL so all data ends up in the
report.

IIF([Forms]![FRM_000_GET_MARKET]![Combo13]=ALL,"",[Forms]![FRM_000_GET_MARKET]![Combo13])

So, THAT doesn't work What's the best way for me to get it? THANKS in
advance for help!