How to create a parameter query where the criteria are chosen from a combo box?

keeling1

Registered User.
Local time
Today, 01:46
Joined
Jun 8, 2009
Messages
27
This is a very simple question, I think. And I'm very much a beginner at Access. But can somebody help me set up a parameter query where the prompt allows the user to only choose from a few select options, rather than having the user enter the information manually?

Basically, I want the query to list data for a particular team. The teams are listed in a table called tblTeams. But I don't want the user to enter the team names manually. I want the prompt to give a combo box which lists the team names from tblTeams.

I've created a form that looks like a dialog and has a combo box called cboTeams, thinking that that might be the way to go. But I don't know how to integrate the form into the query.

Can anyone help?
 
In the criteria row of the query put
Forms!NameOfYourForm!cboTeams

Note that you should run the query from the form as you can't do it the other way round.
 
In the criteria:

Forms!FormName.ComboName

You can right-click in the criteria and choose Build, which will let you navigate to it.
 
Thanks neileg and pbaldy for your quick replies. I've done what you've suggested. But the query isn't working properly. In order to get the form to open the query I added this to After Update Events of the combo box:

Private Sub cboTeam_AfterUpdate()
DoCmd.OpenQuery "qryOpenTagsByTeam", acViewNormal, acEdit
DoCmd.Close acForm, "frmTeams"
End Sub

But it's not working. Please help!
 
in your query

qryOpenTagsByTeam

you need a reference to the combobox in the criteria column, to limit the query results

something like

forms!myform!mycombobox
 
The form needs to be open while the query is.
 

Users who are viewing this thread

Back
Top Bottom