Hi Mike,
I'm sorry but I thought you wanted to have two attachements to your Outlook message; one would be always the same (C:\PDF Files\HowtoCreateCARIAccountV43.pdf) and the other an Access report (rptCariProviderLetter). Now I think this report is (should) showing info for just this CustomerID by using in its criteria a refence to Me.CustomerID (you kinda refer to it but you don't use it anywhere: strWhere = "[CustomerID]=" & Me.CustomerID). So what I suggest is to edit you rptCariProviderLetter report to only return the record(s) for the current customerID loaded in your form.
Now back to emailing,this in itself does nothing, you need to first export the report as a PDF in order to attach it
Code:
30 strDocName1 = "rptCariProviderLetter"
This is how I would try to do it (if my assumtions are correct):
Code:
Private Sub cmdPDF_Click()
On Error GoTo cmdPDF_Click_Error
Dim strSQL As String
Dim objOutlookAttach As Object
Dim objApp As Object
Dim objMailItem As Object
Dim strAttachment As String
Dim strMailItem As String
Dim strWhere As String
Dim strToWhom As String
Dim strMsg As String
Dim strSubject As String
strWhere = "[CustomerID]=" & Me.CustomerID
strToWhom = Me.Email
strSubject = "PDF Guide"
strMsg = "Find attached details of CARI Setup Process"
Set objApp = CreateObject("outlook.application")
Set objMailItem = objApp.CreateItem(0)
objMailItem.Subject=strSubject
objMailItem.To=strToWhom
objMailItem.Body=strMsg
objMailItem.Attachments.Add ("C:\PDF Files\HowtoCreateCARIAccountV43.pdf")
'now lets attach the report
'we need to export it first
strAttachment ="C:\PDF Files\CariProviderLetter_ID" & me.CustomerID & ".pdf"
Docmd.OutputTo acOutputReport, "rptCariProviderLetter", acFormatPDF, strAttachment
'if your report is set to show all customers but you want to send the info just for the current customer comment out the line above and un-comment the three lines below
'Docmd.OpenReport "rptCariProviderLetter", acViewPreview,, strWhere , acHidden
'Docmd.OutputTo acOutputReport, "rptCariProviderLetter", acFormatPDF, strAttachment
'DoCmd.Close acReport, "rptCariProviderLetter", acSaveNo
objMailItem.Attachments.Add strAttachment)
objMailItem.Display 'change to .Display if you want to just display it.
On Error GoTo 0
Exit Sub
cmdPDF_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cmdPDF_Click, line " & Erl & "."
End Sub
Cheers,
Vlad