I have a form with nothing but a combobox and go button. The combobox is populated by the "Name" field in the table. What I want to do, is populate text fields on a new form with the rest of the information in the table, based on what selected in the combobox when "Go" is clicked.

Rab

If your other form is called Form2 then declare a new form of type Form2,Dim NewForm As New Form2,now you have full access to any of the controls in Form2, NewForm.TextBox1.Text = "some string". When that is all done just call the Show method, unless you need a DialogResult returned, or you want NewForm to block the calling form until NewForm is closed, then use the ShowDialog method.

What are you storing these values in, a database?

If so, just write a sub routine that retreives information based on your selected:

Public Class Form1
    Private Sub GO_Click(ByVal sender As Object, ByVal e As EventArgs) Handles GO.Click
        Form2.Filter = ComboBox1.Text
    End Sub
End Class

Code for second form:

Public Class Form2
    Private sFilter As String = String.Empty

    Public Property Filter As String
        Get
            return sFilter
        End Get
        Set(value As String)
            sFilter=value
            PopulateFields()
        End Set
    End Property

    Private Sub PopulateFields()
        Try
            'Place query code here.
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

End Class

What do you maen by "Place Query Code Here"?

Something like:

Dim myCon As New OleDBConnection("ConnectionStringHere")
Dim da As New OleDBDataAdapter(New OleDBCommand("SELECT * FROM " & Filter,myCon))
Dim ds As New DataSet

da.Fill(ds,"MyTable")

If Not IsNothing(ds.Tables("MyTable")) And ds.Tables("MyTable").Rows.Count > 0 Then
    For Each r As DataRow in ds.Tables("MyTable").Rows
        TextBox1.Text = r("MyField1")
        TextBox2.Text = r("MyField2")
        'ect....
    Next
End If

Thats pretty much what I tried, got an error about two bindings. Hmmm

What does the error message state?

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.