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

dynamic combo boxes - help

Status
Not open for further replies.

JSearcy

Programmer
May 13, 2002
3
0
0
US
I have two combo boxes - one fills based on the selection in another. My problem is that the second one (the dependent one) won't let you select from it. It says that the control can't be edited because it's bound -then shows the sql statement. (on the status bar when you click the desired selection.) Does anyone have any ideas on how to either fix this or a work around?

I would be MOST GRATEFUL, as I have wasted too much time on it already.

thanks!
J.Searcy
 
I have always used unbound controls to do this. The OnChange event of the first combo box would have code to set the RowSource of the second combo box. Here's an example:

Dim strQuery As String

strQuery = "SELECT table.[field] FROM table WHERE table.field = '" & CmboBox1.Value & "';"

CmboBox2.SetFocus
CmboBox2.RowSource = strQuery
CmboBox2.Requery
CmboBox2.Value = ctrl.ItemData(0)

If you don't have to use a bound control, you might try this.

dz
 
Sorry, the last line should read:

CmboBox2.Value = CmboBox2.ItemData(0)

I passed ctrl to a procedure, and forgot to change it to CmboBox2 when I posted it here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top