Detecting user changes to data on form
I have a form which is used to make changes to a database.
When the form first opens the form fields are populated from the database. How can I tell if the user changes any of the fields. I would like to be able to detect this so that if the user tries to close the form I can prompt them to see if they wish to save the changes.
Thanks
Hi Carl,
you can use the HasChanges method of the DataSet or the GetChanges method of the DataTable objects.
For example:
If (myDataSet.HasChanges) Then
' Prompt user here
End If
Or for a typed dataset you can do
If (myDataSet.MyTable.GetChanges() IsNot Nothing) Then
' Prompt user here
End If
After you prompt the user, if the user answers 'yes' to save the changes, you can use the DataAdapters to send the changes back to the database.
HTH
Antoine
Visual Basic team