Hey so I'm having some problems with vb.net 2008. I need to create a search form where a combobox populates with names then the user clicks a name and the textboxes in the form are filled with the correct data for example txt_Firstname txt_last txt__nameage would all be filled with the right data from access.

I already have the combobox sorted meaning i can successfully see First names in the combo box so now all i need is helping with clicking a name in the combo box and the dataset being populated in the text boxes
heres the code used to populate the combo box:

Private Sub Search_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        dbprovider = "PROVIDER = microsoft.jet.OLEDB.4.0;"
        dbsource = (" Data Source = C:\Users\SEUN\Desktop\Addressbook.mdb")
        con.ConnectionString = dbprovider & dbsource

        Dim cmd As New OleDb.OleDbCommand("SELECT FirstName FROM tblContacts", con)


        con.Open()

        Dim sdr As OleDb.OleDbDataReader = cmd.ExecuteReader

        While sdr.Read()

            ComboBox1.Items.Add(sdr.Item("FirstName").ToString)
            
        End While

        con.Close()


    End Sub

Thanks in advance

See this example. And try with your codes.

ST = "select * from table1 where empno="
ST = ST + "'" + TxtEmpNo.Text + "'"
cmd = New OleDbCommand(ST, cn) ' where empno=" + "'" + TxtEmpNo.Text + "'", cn)
dr = cmd.ExecuteReader()

dr.Read()
If dr.HasRows Then
   TextBox1.Text = dr("empno")
   TextBox2.Text = dr("Ename")
   TextBox3.Text = dr("Department")
End If
dr.Close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.