Hi All,
My question is with regards to the error handler that I have. The code below is only a partial extract from the code on the form.
Essential the code attaches a report to an outlook message. If the user doesn't send the email, it runs through the error handler and asks the user to resend the email if they click the retry button or closes the form is they click cancel.
I was testing the code and so I closed the email without sending, the message box successfully appeared asking if I wanted to resend the email or close the form, I hit rerty and again closed the email without sending but this time instead of displaying my custom error message it displayed the default message generated by access. "Run Time error: 2501 sendobject method was canceled."
Does anyone notice anything incorrect in my error handler that is causing access not to step through the error handler on the second attempt. Its not really a big issue but I'm just curious to know whats wrong. Hope I have explained the problem in sufficient detail.
Thanks for the help,
ZDog
report:
On Error GoTo Error_handler
DoCmd.SendObject acReport, "repPFA", "RichTextFormat(*.rtf)", Me.cmbAuthorizer.Value, , , "PFA Request", , True
DoCmd.GoToRecord , , acNewRec
MsgBox "Information successfully updated.", vbInformation
Error_handler:
If Err.Number = "2501" Then
response = MsgBox("Email not sent. Please send the PFA to the designated authorizer in order to process the request.", 21, "Error!")
If response = vbRetry Then
GoTo report
ElseIf response = vbCancel Then
cmdClose_Click
End If
Exit Sub
End If
My question is with regards to the error handler that I have. The code below is only a partial extract from the code on the form.
Essential the code attaches a report to an outlook message. If the user doesn't send the email, it runs through the error handler and asks the user to resend the email if they click the retry button or closes the form is they click cancel.
I was testing the code and so I closed the email without sending, the message box successfully appeared asking if I wanted to resend the email or close the form, I hit rerty and again closed the email without sending but this time instead of displaying my custom error message it displayed the default message generated by access. "Run Time error: 2501 sendobject method was canceled."
Does anyone notice anything incorrect in my error handler that is causing access not to step through the error handler on the second attempt. Its not really a big issue but I'm just curious to know whats wrong. Hope I have explained the problem in sufficient detail.
Thanks for the help,
ZDog
report:
On Error GoTo Error_handler
DoCmd.SendObject acReport, "repPFA", "RichTextFormat(*.rtf)", Me.cmbAuthorizer.Value, , , "PFA Request", , True
DoCmd.GoToRecord , , acNewRec
MsgBox "Information successfully updated.", vbInformation
Error_handler:
If Err.Number = "2501" Then
response = MsgBox("Email not sent. Please send the PFA to the designated authorizer in order to process the request.", 21, "Error!")
If response = vbRetry Then
GoTo report
ElseIf response = vbCancel Then
cmdClose_Click
End If
Exit Sub
End If