I am trying to find the VBA code that adds attachments currently stored in the database to an email. Currently, I have a button that will email the report refernced on my input form. My attachments are stored in a table, but I have built a query for my attachments that wil filter based off the referenced report on the input form. Below is my VBA code to email a report. Thanks
Private Sub Command587_Click()
Dim stReport As String
Dim stWhere As String
Dim stSubject As String
Dim NCRNum As String
NCRNum = Forms![NCR Input Form]![NCR #]
stSubject = "Supplier Chargebacks NCR " & NCRNum
stReport = "Supplier Chargebacks"
stWhere = "[NCR #] = " & "'" & NCRNum & "'"
Dim rpt
Dim sRpt As String
sRpt = "Supplier Chargebacks"
DoCmd.OpenReport sRpt, acViewDesign
Set rpt = Reports(sRpt)
rpt.Caption = "Supplier Chargebacks NCR " & NCRNum
'rpt.RecordSource = pvQry
'rpt.OrderByOn = True
'rpt.OrderBy = sFld
DoCmd.Close acReport, rpt.Name, acSaveYes
DoCmd.SendObject acSendReport, stReport, "PDFFormat(*.pdf)", , , , stSubject, , True, ""
DoCmd.Close acReport, stReport
End Sub