Supress Err (1 Viewer)

Horseleach

New member
Local time
Today, 07:07
Joined
Jan 18, 2008
Messages
3
Forgive me I'm new. I wrote this below. It works great. I have a small problem tho. After selecting No, if "Undo" is unavailable an error message pops up and reads "The command or action 'undo' isn't available now." I designed this for firefighters who get confused really easy when it comes to computers. Is there a way for me to suppress the error and for it to continue closing the form?
---------------------

Private Sub Command169_Click()
Dim strMsg As String
strMsg = "Do you wish to save the changes?"
strMsg = strMsg & vbCrLf & ""
strMsg = strMsg & vbCrLf & "Click Yes to Save"
If MsgBox(strMsg, vbQuestion + vbYesNo, "China Lake Fire Training DB") = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
If Me.Dirty Then Me.Dirty = False
DoCmd.Close
Else
On Error GoTo Err_Command199_Click

DoCmd.RunCommand acCmdUndo
DoCmd.Close acForm, "MainInputAdd", acSaveNo

Exit_Command199_Click:
DoCmd.Close acForm, "MainInputAdd", acSaveNo
Exit Sub

Err_Command199_Click:
MsgBox Err.Description
Resume Exit_Command199_Click

End If

End Sub
 

RoyVidar

Registered User.
Local time
Today, 16:07
Joined
Sep 25, 2000
Messages
805
I think perhaps one of the times Undo is available, is when the form is dirty - i e, it has unsaved changes.

You could try the following test/action in stead

If Me.Dirty then Me.Undo

But, what do you do if the record is already saved? The acSaveNo thingie of the DoCmd.Close method, is only good for design changes.
 

Horseleach

New member
Local time
Today, 07:07
Joined
Jan 18, 2008
Messages
3
I think perhaps one of the times Undo is available, is when the form is dirty - i e, it has unsaved changes.

You could try the following test/action in stead

If Me.Dirty then Me.Undo

But, what do you do if the record is already saved? The acSaveNo thingie of the DoCmd.Close method, is only good for design changes.
Worked. Thx.
 

Users who are viewing this thread

Top Bottom