Question : How do I email a pdf report when ID=ID?

I have a MS Access 2007 database.  I currently can email a report as an attachment to an email. The problem is I need to attached a report where the the form invoiceid=the report invoiceid. How do I modifiy the current code to do this?

DoCmd.SendObject acSendReport, invoiceLH, acFormatPDF, _
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
Private Sub Command343_Click()
On Error GoTo Error_Handle
Dim strBody As String
Me.usercompany = DLookup("[companyname]", "tblusersettings")
'Email Client'
strBody = "Dear valued customer," & vbCrLf & vbCrLf & _
"Below you will find your invoice, credit memo, sales receipt, or statment. If you need to remit payment, please do so at your earliest convenience." & vbCrLf & vbCrLf & _
"Thank you for your business- we appreciate it very much." & vbCrLf & vbCrLf & _
"Sincerely," & vbCrLf & _
Me.usercompany
DoCmd.SendObject acSendReport, invoiceLH, acFormatPDF, _
    "" & Me.clientemail, _
    , _
    , _
    "Notification from " & Me.usercompany, _
    "" & strBody, _
    True
Error_Handle:
If Err.Number = 2501 Then
MsgBox "The email was canceled and has not been sent", , "Email Invoice"
Exit Sub
Exit_Error_Handle:
End Sub

Answer : How do I email a pdf report when ID=ID?

Put this line
DoCmd.OpenReport invoiceLH, acViewPreview, , "invoiceid=" Me.invoiceid=,acHidden
in front of the line
DoCmd.SendObject acSendReport, invoiceLH, acFormatPDF, _
and these lines
DoCmd.Close acReport, invoiceLH, acSaveNo
Exit Sub
in front of the line
Error_Handle:

Random Solutions  
 
programming4us programming4us