Click to See Complete Forum and Search --> : Syncronizing Combo Boxes


gypsy74
July 12th, 2001, 05:05 PM
How do I synchronize combo boxes? I have populated combo boxes by loading info into arrays from an access database. I need to synchronize these so that when the first box is selected it populates the information for the second box, and when the second box is selected it populates the information to the third. etc. IE: Clicking the RegionName populates the salesmen for that region, then clicking salesman will populate the customers for that salesman. How do I do this?

Help!!

Cimperiali
July 18th, 2001, 08:03 AM
just a suggestion, build in a hurry to give you an idea:

option Explicit

private Sub Combo1_Change()
'this is regional combo
'Be sure user can only select value here,
'or add code to test for correct values and to avoid
'all the DB stuff for each input char
Dim rs as adodb.Recordset, conn as adodb.connection

'code for your connection...
sql = "select * from salesman where id-region = " & Combo1.Text
'exec the query
set rs = conn.execute(stmSql)
'use recorset to populate the second combo
If rs.EOF = false And rs.bof = false then
Do While rs.EOF = false
Combo2.AddItem rs.fields("SalesmanName").Value
rs.movenext
Loop
else
'if no record, clear the combo2
Combo2.Clear
End If
rs.Close
set rs = nothing
'conn.Close
'set conn = nothing
End Sub





Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.