Default Query Criteria

P

programmingrookie

I have a query which derives its criteria from a combo box on a form. This
combo box contains 5 values, while the underlying table of the query contains
8 values. When a null value is passed to the query because no selection is
made in the combo box, I would like it to default to pull only those records
with the 5 values from the combo box, not all 8 values from the underlying
table. Can a change be made to the criteria:
[Forms]![frmReports]![Criteria] or Like [Forms]![frmReports]![Criteria] is
Null, or should another route be taken?

Thanks
 
A

Allen Browne

Switch the query to SQL View.
Locate the WHERE clause in the query.

It will say something like this:
WHERE [F1] = [Forms]![frmReports]![Criteria]
where F1 represents your field name.
Change it to:
WHERE (([Forms]![frmReports]![Criteria] Is Null) OR ([F1] =
[Forms]![frmReports]![Criteria]))

The important thing here is that the null criteria is not compared to your
field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

message
news:[email protected]...
 

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