I can't seem to successfully deal with this error.
The scenario is as follows. I click a button which launches an email with an attachment, with the option of having the User see it first. That works fine.
If the user chooses to not send the email however, and hits the email's close button to Cancel the send, I get Error 2051 popping up in Access.
I built code to trap the error, but it only works the first time through. For example, If i launch the email and cancel it, the following code kicks in, the user sees the MsgBox regarding the error, and the sub exits gracefully. But if you then try to send the email again, and cancel again, my error code does not get hit, and Access throws up a window saying the SendObject method was canceled. When you click OK, Access is frozen, VBA Editor is frozen. I can't do anything but hear an annoying beep sound every time I click anywhere. CTRL+Break doesn't get me into VBA. I can't get to the Immediate window in the VBA Editor. The only way I've found out of it is to use Task Manager to shut down Access.
I've read some other posts regarding an apparent inability to trap this error.
Does anyone have any ideas? Is there a way to detect this "frozen" state I describe and get out of that, as a work around?
The scenario is as follows. I click a button which launches an email with an attachment, with the option of having the User see it first. That works fine.
If the user chooses to not send the email however, and hits the email's close button to Cancel the send, I get Error 2051 popping up in Access.
I built code to trap the error, but it only works the first time through. For example, If i launch the email and cancel it, the following code kicks in, the user sees the MsgBox regarding the error, and the sub exits gracefully. But if you then try to send the email again, and cancel again, my error code does not get hit, and Access throws up a window saying the SendObject method was canceled. When you click OK, Access is frozen, VBA Editor is frozen. I can't do anything but hear an annoying beep sound every time I click anywhere. CTRL+Break doesn't get me into VBA. I can't get to the Immediate window in the VBA Editor. The only way I've found out of it is to use Task Manager to shut down Access.
Code:
On Error GoTo errHandler
DoCmd.SendObject acSendForm, "frmemailscenarios", acFormatPDF, strTo, , , strSubject, strBody
ExitErr:
Exit Sub
errHandler:
MsgBox "You hit Error # : " & Err & vbCrLf & _
Err.Description
Resume ExitErr
End Sub
I've read some other posts regarding an apparent inability to trap this error.
Does anyone have any ideas? Is there a way to detect this "frozen" state I describe and get out of that, as a work around?