Query result sent to combo box control.

J

Joe R.

I have created a form that allows a user to select a
button which will run a query. I would like the query
results however, to be displayed as selectable items
within a combo box.

I know how to use a combo box to run a query as the form
is open. In my example however, I need the user to be
able to be able to select a different query and thus
results to be posted into the original combo box.

Any and all help would be much appreceated.

Best,
Joe.
 
W

Wayne Morgan

Set the combobox's Row Source to the new query.

Me.cboMyComboBox.RowSource = "SELECT....;"

If it doesn't autorequery when you do this then force a requery.

Me.cboMyComboBox.Requery
 
A

Andrew Smith

You just need to change the RowSource property of the combo box to the name
of the query (or SQL). In the code for the button put:

Me.NameOfComboBox.RowSource = "NameOfQuery"

This will work provided the number of columns set for the combobox matches
the number of columns returned by the query.
 

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

Top