Need help adding a Order ID field number to mailReport click code

Abouya

Registered User.
Local time
Today, 07:15
Joined
Oct 11, 2016
Messages
88
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?


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:
instead of
MsgBox Error$
use
msgbox "my error message"
 
instead of
MsgBox Error$
use
msgbox "my error message"


I have few issues with the sendobject code, instead of getting Requestor name in email message field, i get requestor ID which is just a number. is there a way to fix this.

Thanks,

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], "Requestor: " & Report_ReportOrderDetailQuery![fk_RequestorID] & vbNewLine & "Request Date:" & Report_ReportOrderDetailQuery![RequestDate], True, ""
    Beep
    MsgBox "Your email was successfully sent!", vbOKOnly, ""


MailReport_Click_Exit:
    Exit Sub

MailReport_Click_Err:
    MsgBox "The operation was cancelled"
    Resume MailReport_Click_Exit
   
   End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom