CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2001
    Posts
    1

    Syncronizing Combo Boxes

    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!!


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Syncronizing Combo Boxes

    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.
    ...at present time, using mainly Net 4.0, Vs 2010



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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured