Email Report - PDF not SNP - Need Help

J

JK

Currently, in my database, I'm able to use a command button to send a report
in SNP format. I'm trying to find some help convert this code (posted below)
so that it generates a report & attaches it to an email in PDF format -
again, not SNP. I'm hope a few simple changes will do the trick... Thx!!!!

Private Sub cmdMailFinishedWorkorderReport_Click()

'**********************
'Developed by Mike Buraczewski

Dim MailList As String
Dim strCCTo As String
Dim strBccTo As String
Dim strmsg As String
Dim Address As Variant
'Report variables
Dim strFilter As String
Dim rpt As String

'Create string for list of mail recipients
'lstMailer is a multiselect listbox
For Each Address In Me.lstMailer.ItemsSelected
MailList = MailList & ";" & """" & Me.lstMailer.ItemData(Address) & """"
Next Address
If MailList = "" Then
MailList = ""
Else
MailList = Right(MailList, Len(MailList) - 1)
End If
'**********************
'set report to print
rpt = "Finished Workorders Past Week" 'report name goes here. This is the
name of the report you wish to send.
strFilter = "" 'add code to create filter for report if necessary

strCCTo = "" 'Additional email addreses go here
strBccTo = "" 'Additional blind email addrresses go here
strmsg = "" 'Default message content goes here

DoCmd.OpenReport rpt, acPreview, , strFilter
'The next line sends the report in RTF format.
'This can be changed to several formats, search the help file for acFormatRTF

DoCmd.SendObject acSendReport, rpt, acFormatSNP, MailList, strCCTo,
strBccTo, "Finished Workorders", strmsg, -1
DoCmd.Close
MsgBox "This form is incomplete." & vbNewLine & vbNewLine & "Modify the code
per the in-line comments", , "Send E-Mail"
Exit_cmdPrint_Click:
Exit Sub

Err_cmdPrint_Click:
MsgBox Err.Description
Resume Exit_cmdPrint_Click

End Sub
 
T

Tony Toews [MVP]

JK said:
rpt = "Finished Workorders Past Week" 'report name goes here. This is the
name of the report you wish to send.
strFilter = "" 'add code to create filter for report if necessary

You can't use a filter on the docmd.OpenReport when you are creating a
PDF file.

For a page on how to print a report for a single record and how to
generate reports to attach to emails see the Emailing reports as
attachments from Microsoft Access page at
http://www.granite.ab.ca/access/email/reportsasattachments.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top