How to bind controls to a data source in VB.Net

I have a  Query in MSAccess named "EMPLOYEE", In form I have a combobox that shows the employeecode field of the query.  I would like to select an employeecode from the combobox and this should display the corresponding fields like
employeename in the textbox1  and functioncode in textbox2 and functiontitle in the textbox3, all these fields are in the same record(row) as the selected employeecode, the next operation is I want to edit this record and make some modifications, for example in the employename or employeecode and send the modification back to the query, so that it gets updated.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

something like

txtEmployeeName.DataBindings.Add(New Binding("Text", Me.Dataset1, ""

then, in your combobox_selectedindexchanged event set Me.BindingContext(Dataset1, "EMPLOYEE").Position = the dataset row # of that employee

There's a better way, i'm sure, but you could just ...
Dim i as integer
For i = 0 to Dataset1.EMPLOYEE.Rows.Count - 1
    If Dataset1.EMPLOYEE.Rows(i).Item("code") = combobox1.selecteditem.value '// or however you're getting the code
        me.bindingcontext(dataset1 "EMPLOYEE").Position = i
    End If
Next i

then ... any controls you have bound to EMPLOYEE fields will update.  Don't know if you need to loop like my code ... you can grab your EMPLOYEE row if you just : Dim row as myDataset.EMPLOYEERow = Dataset1.EMPLOYEE.FindByCode(code) ... and it gives you the datarow, but i don't know howto get the dataset row # as easily.

hope that helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChuckbuchanAuthor Commented:
I can edit the fields, but the problem is when I modify any of these fields , it doesn't get updated in the table.

here is my code

 If ComboBox1.SelectedItem Is Nothing Then
            Exit Sub


            Me.TextBox1.DataBindings.Add("Text", ComboBox1.SelectedItem, "employeename")
            Me.TextBox2.DataBindings.Add("text", ComboBox1.SelectedItem, "functioncode")
            Me.TextBox3.DataBindings.Add("text", ComboBox1.SelectedItem, "functionlabel")
        End If
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.