Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo box in query criteria 1

Status
Not open for further replies.

rutager

Technical User
Mar 29, 2001
2
US
I have a query where I want a combo box listing a table to come up when the user is inputting criteria. I tried to create a form using the control wizard to specify what I wanted to do with the data, as stated in the help file, but the question was never asked in the wizard.
Thanks,
rutager
 
Hi,
Are you trying to have the user select a field value from a combobox that will be used by your query? If so, you can create a form, a command button, and put a combobox on it call it cboCriteria, set its recordsource to a query/sql statement that will supply its field values.

In your query make a reference to the combobox like: forms!frmRunQuery!cboCriteria.
Run the query from a command button click event on your form with the code docmd.openquery "Myqueryname"

Have a good one!
BK
 
OK, I tried BK's suggestion and it seemed to work except the info is not passed on to the query. I tried the same form, substituting a text box for the combo box and the proper info was passed on to the query as I typed it in. It did not work with either a combo box or list box. I have over 900 items in the list for people to choose, and it has to be input exactly, hence the drop down choice rather than a text box input. Any more suggestions?

Thanks,
Rutager
 
Hi,

Did you make sure that the bound column is the column that contains the criteria you want to search for?

In cboCriteria I used a query (qryPatients) for the rowsource, which shows the LastName, and FirstName fields in that order. I have another query which I want to execute when the user selects a name from the combobox.

The query I want to execute is qryGetMedicare which displays the fields: LastName. FirstName, MedicareNum. Under the LastName field in this query I put the parameter: forms!form1!cboCriteria and it worked like a charm.

Have a good one!
BK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top