My application provides the user the ability to add, edit or delete records from any of the many tables in an Access db. On exiting the app, I want to check if any changes have been made to the database. I have not yet found a way to do this-any ideas?
If you are working in Access97, here's one way, using the 'Dirty' and 'OldValue' properties. If you're working with Access 2, you have to keep track of the data you are able to change, then make a DB call before you exit.<br>
<br>
<br>
Sub UndoEdits()<br>
If Me.Dirty Then<br>
Me!btnUndo.Enabled = True ' Aktivera knappen.<br>
Else<br>
Me!btnUndo.Enabled = False ' Inaktivera knappen.<br>
End If<br>
End Sub<br>
<br>
Sub btnUndo_Click()<br>
Dim ctlC As Control<br>
' För varje kontroll.<br>
For Each ctlC in Me.Controls<br>
If ctlC.ControlType = acTextBox Then<br>
' Återställ gammalt värde.<br>
ctlC.Value = ctlC.OldValue<br>
End If<br>
Next ctlC<br>
End Sub<br>
<br>
The 'Dirty' and 'OldValue' properties apply to Access Forms. Since your question disdn't sepcify how you were modifyinbg your data, I chose q&d solution. If you are NOT using forms, plan B sez do like you'd do it in Access 2: Save the original values when you load the record into the application, then check the database for any change before you let the user leave. To be smart - save enough info so you can hit the record with a unique, indexed key (saves time), and since you are hitting multiple tables, use transactions, so you can roll back the whole schmear if anything goes BillGates.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.