I would like to prompt users after they change/create a record on a form to verify that they really want the changes. Here is the code I have...
Private Sub Form_AfterUpdate()
Dim s As Byte
s = MsgBox("Do you want to save your changes?", vbYesNo, "Save"
If s = vbYes Then
On Error GoTo SAExit
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
SAExit:
If Err <> 0 Then
MsgBox Error$, vbCritical
End If
Exit Sub
Else
If Me.Dirty Then Me.Undo
End If
End Sub
The only problem is when the user selects no, Me.Dirty is showing false when I step through the code even when the records have been changed (the changes are not getting undone). What am I doing wrong or what other options do I have.
thanks in advance
Private Sub Form_AfterUpdate()
Dim s As Byte
s = MsgBox("Do you want to save your changes?", vbYesNo, "Save"
If s = vbYes Then
On Error GoTo SAExit
On Error Resume Next
DoCmd.RunCommand acCmdSaveRecord
SAExit:
If Err <> 0 Then
MsgBox Error$, vbCritical
End If
Exit Sub
Else
If Me.Dirty Then Me.Undo
End If
End Sub
The only problem is when the user selects no, Me.Dirty is showing false when I step through the code even when the records have been changed (the changes are not getting undone). What am I doing wrong or what other options do I have.
thanks in advance