Making a combo box query EITHER OR instead of all.

G

Guest

I have a query which has three parameters determined by combo boxes in a form.

But the query only runs if all three combo boxes have a value selected, how
can I change the query such that if only 1 or 2 out of the 3 boxes have a
record seleted the query still runs as at the moment if you try and run it
with only 1 or 2, no records are displayed.
 
A

Arvin Meyer

Richard Horne said:
I have a query which has three parameters determined by combo boxes in a form.

But the query only runs if all three combo boxes have a value selected, how
can I change the query such that if only 1 or 2 out of the 3 boxes have a
record seleted the query still runs as at the moment if you try and run it
with only 1 or 2, no records are displayed.

In the afterupdate event of each of the combo boxes, use a Select Case
statement to run the SQL rowsource. The Select Case statement should have 3
cases and a case else (for possible unexpected errors).
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
L

Larry Daugherty

In the criteria line for each field that gets its argument from one of those
comboboxes put

Like "*" & forms!myform!mycombobox

That way, if the relevant combobox is empty then the criteria for the field
is "*" or ~no or any characters~

HTH
 

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

Similar Threads

Blank combo or list box 1
Combo Box Question 4
Populate combo box from current record 3
VBA query 4
Combo box item selesction 3
Parameter Query With Null Values 3
Combo Boxes on Form 2
List Box Query - Forms 3

Top