DavidCantor
Registered User.
- Local time
- Today, 01:45
- Joined
- Oct 4, 2012
- Messages
- 66
I am trying to code a y/n/cancel message box, the yn works but the cancel gives me an error
the error I am getting is
and when I debug it takes me to this line:
can anyone help me fix this?
thanks!
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer
' Specify the message to display.
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes or Cancel to go back."
' Display the message box.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNoCancel, "Save Record?")
' Check the user's response.
If iResponse = vbNo Then
' Undo the change.
DoCmd.RunCommand acCmdUndo
' Cancel the update.
Cancel = True
ElseIf iResponse = vbCancel Then
'Cancel Close, continue editing
DoCmd.CancelEvent
End If
End Sub
the error I am getting is
Code:
Run Time error '2001'
You cancelled the previous operation
and when I debug it takes me to this line:
Code:
Me.Dirty = False
can anyone help me fix this?
thanks!