mistyinca1970
Member
- Local time
- Yesterday, 17:23
- Joined
- Mar 17, 2021
- Messages
- 117
I have the following error handling added to a button, but I want to add another handling for another type of error. This one in particular is if the user fails to select a report from the list box prior to clicking the "Email Report" button.
But I also want to add a custom message for if/when the user closes the email and doesn't send it. I have this code, but I don't know how to insert it with the other error handling.
Code:
Private Sub btnEmailReport_Click()
On Error GoTo btnEmailReport_Click_Err
DoCmd.SendObject acReport, lstReportList, "PDFFormat(*.pdf)", TempVars!EmailAddress, "", "", "Contrax™ " & lstReportList, "This is an AUTOMATIC NOTIFICATION sent from Contrax™. Please see the attached Report. You may direct any questions regarding this report to Mickey Mouse.", True, ""
btnEmailReport_Click_Exit:
Exit Sub
btnEmailReport_Click_Err:
MsgBox "You must first select a report from the List Box.", vbOKOnly, "No Report Selected"
Resume btnEmailReport_Click_Exit
End Sub
But I also want to add a custom message for if/when the user closes the email and doesn't send it. I have this code, but I don't know how to insert it with the other error handling.
Code:
Cleanup:
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 2501
MsgBox "Your email message has been canceled.", vbOKOnly, "Email Canceled"
Case Else
MsgBox Err.Number & ": " & Err.Description
End Select
Resume Cleanup