Save Report to PDF in designated folder

lunchbox

New member
Local time
Today, 17:29
Joined
Sep 27, 2017
Messages
5
Hi Guys,

I'm after some guidance please as I’m sure I’m going a long and complicated way about things here.

Basically I have a report that’s generated from a query to select the current viewed record in a form.

What I want to do is click a button on the form and have the report print 3 times and save as a pdf in a specific folder with the name taken from the report.

I can get it print 3 times and export to a pdf with the name taken from the report I just can’t get it so save in a folder of my choosing (C:\exports).

The code I have so far is:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "Bedfords", acViewPreview
DoCmd.PrintOut , , , , 3
DoCmd.OutputTo acOutputReport, Bedfords, acFormatPDF, Me.Customer_Order_Number & ".pdf", True, "", 0

Could someone please point me in the right direction to add in the folder I want to export it to?

Thanks in Advance
 
vRpt = "rMyReport"
vFile = "c:\folder\" & vOrderNum & vRpt & ".pdf"
docmd.OutputTo acOutputReport ,vRpt,acFormatPDF,vFile
 
There's a little missing from that. More simply:

Code:
DoCmd.OutputTo acOutputReport, Bedfords, acFormatPDF, "C:\exports\" & Me.Customer_Order_Number & ".pdf", True, "", 0
 
Thanks for the quick reply guys.

When Im running the script I get 2501 error (Picture attached).

Any Ideas?

Thanks
 

Attachments

  • snip.JPG
    snip.JPG
    15.8 KB · Views: 216
Please ignore my last message I has mistyped exports for the actual folder on C.

All is now working thanks so much for your help.
 
Make sure the folder exists, and that you have permission to save to it. I assume you're getting the printouts so the report opens okay?
 
Ah, glad you got it sorted.
 

Users who are viewing this thread

Back
Top Bottom