Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27415

Return an Access DB value based on combobox value

$
0
0
Hi - I have read many posts on this, and (as a beginner) cannot get this to work, so am seeking advice please.

My access database has two tables. The first table ("Advisers") simply contains two columns for Username and Full Name. It is linked to the second table ("NewBus") via "Username". The second table has many columns of information about that user.

I have a form with a combobox. I can already get that list pre-populated with all the "Full Names" from table one. When I hit my GO button, I would like to return a value from table 2 (inserted into textbox1) from the corresponding Fullname that was selected.

NB - ultimately I want to populate several textboxes, but just need to know how to do one at this point.

This code just pulls out a random entry from the bottom row of my table, and I don't really understand what it is doing to be honest.. so can't fix it.

Many thanks inadvance

Code:

   
Dim cn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=u:\test\test3.mdb")
    Dim da As New OleDbDataAdapter()
    Dim ds As New DataSet
    Dim dt As New DataTable()

    Private Sub Export_Click(sender As System.Object, e As System.EventArgs) Handles Export.Click

        cn.Open()
        da.Fill(ds, "Fee")
        dt = ds.Tables("Fee")

        If dt.Rows.Count > 0 Then
            For i = 0 To dt.Rows.Count - 1
                TextBox1.Text = dt.Rows(i).Item(0)
            Next
        End If

    End Sub


Viewing all articles
Browse latest Browse all 27415

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>