Adding a combo box to query

mattv10

Registered User.
Local time
Yesterday, 21:08
Joined
Jul 24, 2006
Messages
20
Hi,

I'm trying to add a combo box to my query so when I select the item from the combo box it executes my query. I don't know where to begin... Any help??
 
first if you want to have any code execute when a combo box's selection/value changes then you need to run code on the OnChange event of that control

and if you want to run a query through code and include the value of the combo box, you can use the .value propery within the string to call back the value of that combo box.

i.e.
Code:
strSQL = "SELECT * FROM tblMain WHERE FieldName='" & cboSomething.Value & "';"
 
elbweb said:
you need to run code on the OnChange event of that control

Actually, the After Update event would be more appropriate in this instance.
 
The other option is to create a form with a combo-box. Then have the query called when the option is selected (change the event properties of the combo-box).

Pretty much my whole database works on this structure.
 
Ok, I've created a form with a combo box and then created a query. In the criteria section of the query I typed this: [Forms]![Form1]![ComboBox1].. However I noticed the form has to be open first in order for the query to execute.. However, when I went to select another choice from the combo box the query did not change??? Am i missing something??

Thanks for the help!
 
I know, Access won't automatically regenerate the query. You have to close the query and reselect an option.
 
Ouch!! Is there anyway around this. The company I'm working for wants a query where you could type something in a textbox and see its other information. For example if you type an athletes name it would display his/her statistics, years of play, etc etc... So, I thought it would be easier to select from a textbox, but there is no way to get around this????

Thanks!
 
Hi Matt,

I believe their is some functionality to embed queries/forms into an existing form. Maybe that would apply better to your needs, but unfortunately I am beginning to get out of my element. Good luck!
 

Users who are viewing this thread

Back
Top Bottom