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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change control(?) source of Combo Box programmatically

Status
Not open for further replies.

kptasteve

Programmer
Nov 2, 2002
43
US
I have a combo box on a form cmbCombo48 that gets its data information from a query. I then use it to select and fill in text boxes. What I Would like to do is use a command button to change the source of the information data that the Combo box is using. That way I can vary the information to put in the text box. How can this be done.

Steve Marcum PT
Programmer - Physical Therapist
 
Create a command button. In this example it's named "btnMyButton". Create an event procedure for the button's On Click event that looks something like this...

Code:
Private Sub btnMyButton_Click()
Dim SQLStmt As String
SQLStmt = "SELECT ... (your new query statement here)"
Me!cmbCombo48.RowSource = SQLStmt
End Sub

Ken S.
 
One more thing... You might need to requery the combo box for the new rowsource to take effect, so...

Code:
Private Sub btnMyButton_Click()
Dim SQLStmt As String
SQLStmt = "SELECT ... (your new query statement here)"
Me!cmbCombo48.RowSource = SQLStmt
Code:
Me!cmbCombo48.Requery
Code:
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top