I have a form with 10 Textboxes and a ListBox with Acess Database. Opening the form will populate the ListBox and the text fields with the same record. Using VB6 No problem with ListBox code like
Click on item in ListBox wiil fill textfields with data for the selected item. Code like.Code:Private Sub OpenRs() With objRs .Source = "select * from Employee order by LastName" .Open Set DataEmployee.DataSource = objRs End With objRs.MoveFirst showCurrentRec Exit Sub Private Sub showCurrentRec() Dim I As Integer With objRs For I = 1 To .Fields.Count - 1 txtEmployee(I - 1).Text = .Fields(I) & "" Next I End With End SubCode work perfectly with the listbox.Code:Private Sub lstSelCust_Click() objRS.MoveFirst objRS.Move (lstSelcust.ListIndex) showCurrentRec Exit Sub
How do I adapt the code when I rather use a DataGrid in place of the ListBox to get the same results. Need to change the code for Private Sub lstSelCust_Click(). Tried every thing but nothing works. Want to use the data in the DataGrid field "EmployeeID" to populate the textfields. In other words objRS.move to the record where the Employee ID in the DataGrid match.
Any sample code will be appreciated


Reply With Quote