Results 1 to 2 of 2

Thread: populating a datacombo based on the results of another

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2002
    Posts
    8

    populating a datacombo based on the results of another

    i am trying to populate a datacombo box based on what has been chosen from another using the following code:

    Dim RS As ADODB.Recordset
    Set RS = New ADODB.Recordset

    Dim strProductType As String
    strProductType = DataComboType.Text
    Dim descSQL As String
    descSQL = "SELECT Product.Description FROM ProductType INNER JOIN Product ON ProductType.TypeCode = Product.TypeCode WHERE ProductType.Description= '" & strProductType & "'"
    Set RS = Conn.Execute(descSQL)
    RS.MoveFirst
    Do While Not RS.EOF
    DataComboProduct.RecordSource = descSQL
    DataComboProduct.ListField = RS.Fields(0)
    RS.MoveNext
    Loop

    However, the second combo box does not populate at all - why is this? Thank you!

  2. #2
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    Datacombo is not populated with a loop because it is a data bound control.

    Set RS = Conn.Execute(descSQL)
    Set DataComboProduct.RowSource = RS
    DataComboProduct.ListField = RS.Fields(0)
    'in order to make the first item appear in the box
    DataComboProduct.DataField = RS.Fields(0)
    VB 6.0, Access, Sql server, Asp

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