locked
Combo box and text box in vb6 RRS feed

  • Question

  • Please i need help, i want to retrieve an ID from the database and populate it in combo box, and when i click on some of those ID's in the combo box, the corresponding name from the database should appear in a text box. so please check the code below and tell me what is wrong. Thank You Please is in vb6

    -----------------------------------------------------------------------------------------------

    Private Sub Combo2_Click()

    txtFulname.Text = ""

    Adodc2.ConnectionString = "DSN=churchms"
    Adodc2.RecordSource = "Select * from memrectab"
    Adodc2.Refresh

    With Adodc2.Recordset

    Do Until .EOF
    Adodc2.RecordSource = "select fname, sname from memrectab where memrectab.memID = '" & Combo2.Text & "'"

    txtFulname.Text = .Fields("fname") & " " & .Fields("sname")
    .MoveNext
    Loop

    End With
    End Sub




    Private Sub Form_Load()
    Adodc1.ConnectionString = "DSN=churchms"
    Adodc1.RecordSource = "Select * from memrectab"
    Adodc1.Refresh
    With Adodc1.Recordset
     .MoveFirst
    Do Until .EOF
    'Do While Not .EOF
    Combo2.AddItem .Fields("memID")
    .MoveNext

    Loop

    End With
    Set Adodc1.Recordset = Nothing
    End Sub


    • Edited by sammy Iky Thursday, June 12, 2014 5:49 AM
    • Moved by Carl Cai Friday, June 13, 2014 1:53 AM (from vb)vb6 is not supported
    Thursday, June 12, 2014 5:47 AM

Answers

  • See here for information about how to get assistance with VB6 questions:  VB6 and older
    • Proposed as answer by Cor Ligthert Thursday, June 12, 2014 9:14 AM
    • Marked as answer by Just Karl Thursday, June 26, 2014 5:59 PM
    Thursday, June 12, 2014 6:33 AM