Link to home
Start Free TrialLog in
Avatar of Megin
Megin

asked on

Query using multiple parameters?

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.
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Megin
Megin

ASKER

Helen,

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?
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.
Avatar of Megin

ASKER

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:

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

MacroShadow
Experts-Exchange Cleanup Volunteer
If you need more help, you could try the new Live feature, or post a gig.