Ask before saving after a change

GregSmith

Registered User.
Local time
Today, 14:58
Joined
Feb 22, 2002
Messages
126
Here is the code that I am using on a before update event:

Private Sub Media1_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

DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If

End Sub

And this is what I get:

Getting runtime error 2046
The command or action 'Undo' is unavailable right now.

I am on Access 2000

[This message has been edited by GregSmith (edited 05-09-2002).]
 
Private Sub Media1_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
Me.Undo
Cancel = True
End If

End Sub


[This message has been edited by Jack Cowley (edited 05-09-2002).]
 

Users who are viewing this thread

Back
Top Bottom