Monday, August 16, 2010

VB - Datagrid Question?

Hi,





i have a form linked up to a Ms Access database, the form has a tab, on 1 tab is text boxes and the individual records load in to the specific text boxes eg, surname in to the surname text box..on the other tab is a datagrid which displays all of the records.





I've used the click procedure so that when the datagrid is clicked whatever row it is on the record will load in to the text boxes on the other tab.





That works fine, my problem is that i when i want to update the record it is saving the details to the 1st record in the database, how can i point and save it to the specific record i have loaded? e.g i load the user with Id #7 from datagrid but it saves it to the user with Id #1





The datagrid click code looks like this





txtID.Text = Datagrid.Columns(0)


txtSurname.Text = Datagrid.Columns(2)


txtForename.Text = Datagrid.Columns(1)





the update record code is like this





txtID.Text = rs![Employee_id]


rs![Surname] = txtSurname.Text


rs![Forename] = txtForename





i know i can use the datagrid to update a record, but i would just like to do it this way, i hope some of you can help,





need any more info just let me know, thanksVB - Datagrid Question?
Before updating the records you must the conditions that is the ID values are equal means it did update otherwise rs.moveNext()...





you put the condition statements before you update the values....





bye

No comments:

Post a Comment