Email PDF from Access 2007 using VBA (1 Viewer)

TallblokeUK

New member
Local time
Today, 07:50
Joined
Aug 7, 2008
Messages
2
As it stands my users fill in a form, click print and a report is popped in an envelope and sent to our customer.

BUT, We're using Access 2007 and what I want to happen is...

My users fill in a form, click attach and an Outlook email message is opened, the report is turned into a pdf and attached.

It's been a LONG time since I created the database, and I would almost say I'm a beginner again. I know how to get access to open an email and set the address, subject and fill in the body etc, it's just the creating and attaching of the report!

Any help would be much appreciated!
 

zanaeira

Registered User.
Local time
Today, 07:50
Joined
Aug 8, 2008
Messages
18
Hey, I recently had to look into doing something very similar to this with my Access '07 database too.

Firstly what I want to ask is this: when the report is opened and printed, is its record source set to a parameter query? (The parameter being provided by the form your users fill out). Because the method I used and am going to show you uses this type of record source.

So basically, place a code such as this on the On Click event for your "Attach" button:

DoCmd.SendObject acSendReport, "MyReportName", acFormatPDF, [To], [Cc], [Bc], [Subject],[MessageText],[EditMessage],[TemplateFile]

The acSendReport part takes care of attaching the report (specified by "MyReportName"), acFormatPDF converts it to a PDF file.

The reason I asked if the record source of your report is a parameter query is that unless it is, the PDF of the report attached will contain all the records displayed in the report. Whereas if its record source requires a parameter from the calling form which is already filled out by your user, then this problem is overcome as it will send a PDF of the report filtered to only display the particular users filled in form.

Hope this helps. If not let me know and I'll try my best to help you out. :)
 

TallblokeUK

New member
Local time
Today, 07:50
Joined
Aug 7, 2008
Messages
2
That worked like a charm, thanks :)
 

Funkbuqet

Registered User.
Local time
Today, 01:50
Joined
Oct 30, 2010
Messages
50
Is there a way to specify what the name of the outputted PDF file will be?
 

Minddumps

Registered User.
Local time
Today, 02:50
Joined
Jul 5, 2011
Messages
73
Is there a way to specify what the name of the outputted PDF file will be?

Funkbuqet: did you ever figure out if there was a way to specify the name of the outputted pdf file?
 

Funkbuqet

Registered User.
Local time
Today, 01:50
Joined
Oct 30, 2010
Messages
50
Funkbuqet: did you ever figure out if there was a way to specify the name of the outputted pdf file?

Minidumps, yes I did. I was unable to use DoCmd.SendReport however. I ended up using
Code:
DoCmd.OutputTo acOutputReport, "ReportName", acFormatPDF, "PathAndFileName", [AutoStart]

And then had to include the PathAndFileName as an attachment in the e-mail compsition code.
 

Users who are viewing this thread

Top Bottom