|
) Use the form's BeforeUpdate event to run code each time Access tries to save a record. This way, if the user doesn't want to save a record, you can issue an Undo command instead of saving the record.
Note: This will generate a Message Box asking for confirmation each time a changed record is saved. I leave it on whoever is going to follow this method to determine how to refine this per user preference. (Hint: Try a Checkbox.)
'****************** Code Start ******************
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "@Do you wish to save the changes?"
strMsg = strMsg & "@Click Yes to Save or No to Discard changes."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?") = vbYes Then
'do nothing
Else
DoCmd.RunCommand acCmdUndo
'For Access 95, use DoMenuItem instead
'DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
End Sub
'****************** Code End ******************
|
|