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

Change combo box property

Status
Not open for further replies.

kptasteve

Programmer
Nov 2, 2002
43
0
0
US
I have a form with a combo box. I want to keep the control source the same but change the row source for the combo box to different tables based on the on click event of a command button. How do I change the row source property programmatically.

Steve Marcum PT, CSCS
Programmer
 
Combo boxes have a RowSource property. This is the property you can set through code. Set it to a table, query or SQL statement.

Hope that helps

-Gary
 
Changing the RowSource of a combo or list box is easy and can be very functional. You just need to make sure that you are replacing a RowSouce with a similar rowsource (same number of fields, etc.) You could use code such as the following:

Code behind the OnClick

'configure and populate the dropdown list

Me!yourControl.RowSourceType = "Table/Query"
Me!yourControl.RowSource = "qryName"

or

Me!yourControl.RowSourceType = "Value List"
Me!yourControl.RowSource = "Value1;Value2;Value3, etc."

HTH

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top