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

Show different comboboxes depending on value in another combobox???

Status
Not open for further replies.

schredder

Technical User
Feb 6, 2003
48
AE
Hi, need help please with a client database.
Have a combobox in which one can select from A,B,C and D. In the same form when selecting "A" the 2nd combobox appears where one then can select between E and F.
But when in the first combobox B is selected, in the 2nd combobox one then should select between G and H (and so on with C and D chosen in the first combobox). Any help is gr8ly appreciated. Thanks.
Chris, Zurich(Switzerland)
 
This may be a bit of an overkill, but it will work as I've done it recently. I had 2 combo boxes, Program and Vendor. Based on the selection in the Program box I allowed a different set of Vendors in the Vendor box. I have a program table and a vendorprogram table which are linked by Vendor ID. When a program is selected, I set the vendor combo box selection to null and when the vendor box gets focus I call the following code:

Private Sub cboVendorSchedule_GotFocus()

Dim strSQL As String
strSQL = "SELECT tblVendor.VendorID, tblVendor.VName, " & _
"tblVendor.VSite, tblVendor.VProjectID " & _
"FROM tblVendor INNER JOIN tblVendorProgram " & _
"ON tblVendor.VendorID=tblVendorProgram.VendorID " & _
"WHERE tblVendorProgram.ProgramCode=Forms!frmSchedule!ProgramCode"

Me.cboVendorSchedule.RowSource = strSQL

End Sub

I don't know if you want to go to the trouble of setting up a table for E, F, G and H related to a table for C and D, but it does seem to work for me.

Good Luck. P.S. I was in Switerland last May and wish I were there now. Dave (Fargo)
 
Hello,

Another way would be. Have a combo box with value list showing A - D. on the after update event use the following code :-

Select Case Me!cbo1
Case "A"
cbo2.RowSource = "E;F"

Case "B"
cbo2.RowSource = "G;H"

Case "C"
cbo2.RowSource = "I;J"

Case "D"
cbo2.RowSource = "K;L"


End Select

This is assuming your combo boxes are called cbo1 and cbo2.

Cheers,

Steve Make things as simple as possible — but no simpler.
 
Dave, Steve...thanks a lot...implemented steves sugg....worked. u r hammers !!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top