wedd
01-17-2011, 03:14 AM
Hi, I created a save button with options to either save the record yes or no. When I click on no option the following error message appears. "Run Time error '2046': The command or 'Undo' isn't available now", However when I click yes nothing happens. Why has this occured and how can I hide this message?
I've written the code out below:
Thanks for your contributions:friends:
Private Sub Command21_Click()
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."
' Display the message box.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
' Check the user's response.
If iResponse = vbNo Then
' Undo the change.
DoCmd.RunCommand acCmdUndo
' Cancel the update.
End If
End Sub
I've written the code out below:
Thanks for your contributions:friends:
Private Sub Command21_Click()
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."
' Display the message box.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")
' Check the user's response.
If iResponse = vbNo Then
' Undo the change.
DoCmd.RunCommand acCmdUndo
' Cancel the update.
End If
End Sub