We help IT Professionals succeed at work.

Query using multiple parameters?

Megin asked
Last Modified: 2016-06-15
I want to run a query based on options selected in a drop down menu on a form.

I want the user to be able to pick what parameters he/she will use.

However, the query will only run based on 1 of the parameters I have set up and won't run on the others.

My form has the following combo boxes: cmbTeam, cmbTO, and cmbSTO.

I have the query set up so that, in the query builder under the field, it says "[forms]![frm_ParameterRpt]![cmbTeam] or like [forms]![frm_ParameterRpt]![cmbTeam] is null"

I have that for each field I want the user to be able to filter by.

However, something weird is happening.

When I set this up the first time, I put the "[forms]![......" in the cmbSTO field first. I set up the parameters for the other fields, but the query will only run for the cmbSTO parameter.

I reset everything up, but put the parameter in for cmbTeam first. Even though all the other parameters are listed, it will only run the query for cmbTeam.

I am really confused. Does someone know what is going on?

And, I apologize if my wording is super poor. I am happy to explain further.
Watch Question

Owner, Dev-Soln LLC
Most Valuable Expert 2014
Top Expert 2010
This one is on us!
(Get your first solution completely free - no credit card required)
Top Expert 2009
This one is on us!
(Get your first solution completely free - no credit card required)



I really like the way your form works, but I am not sure I understand the code behind it. Where is "pstr" coming from, and the word "filter" is listed at the end of several of these items.

Are these standard parts of VBA?

Am I missing something in this database?
Top Expert 2009

The variables starting with "pstr" are public variables, declared in the basUtilities standard module.  I include the work "filter" in them because they are all String variables.  The combo boxes have values of different data types (Numeric, String and Date), but the AfterUpdate code for each combo box creates a String variable, using the appropriate delimiters.  These variables are used to create the concatenated filter (see the code on the Create and Apply Combined Filter button).  The code on this button concatenates all the separate filter strings into a single concatenated filter, and then applies it to the subform to display the filtered records.


Okay, so I tried to work with the code behind the Fancy Filters Sample Database and just got really, really confused. My VBA coding just isn't there yet.

I am now trying to work with that SQL code, but right now it isn't doing anything when I use it. But I am not sure if I have it in the editor correctly.

What I have now is:
Private Sub btn_Ok_Click()
Dim strsql As String

strsql = "select (all that sql code)

DoCmd.OpenQuery "Qry_Parameters_Rpt"

Open in new window


No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

-- Dale Fye (Access MVP) (https:#a40289444)
-- Helen_Feddema (https:#a40290620)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Experts-Exchange Cleanup Volunteer
Top Expert 2009

If you need more help, you could try the new Live feature, or post a gig.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.