Hello,
I'm using this code to email a report, is there a way to add a custom error message instead when not sending the email?
Thank you.
I'm using this code to email a report, is there a way to add a custom error message instead when not sending the email?
Code:
Private Sub MailReport_Click()
On Error GoTo MailReport_Click_Err
Dim emailto As String
emailto = List5.ItemData(List5.ItemsSelected.Item(0))
If StrPtr(emailto) = 0 Or Len(emailto) = 0 Then
Cancel = True
Else
DoCmd.SendObject acReport, "ReportOrderDetailQuery", "PDFFormat(*.pdf)", emailto, "", "", "PO Requisition #" & Report_ReportOrderDetailQuery![RequisitionID], "", True, ""
Beep
MsgBox "Your email was successfully sent!", vbOKOnly, ""
MailReport_Click_Exit:
Exit Sub
MailReport_Click_Err:
MsgBox Error$
Resume MailReport_Click_Exit
End If
End Sub
Thank you.
Last edited: