Access Report to PDF to Save (1 Viewer)

Sreemike

Registered User.
Local time
Today, 09:04
Joined
Jan 20, 2012
Messages
31
I want to click a button and various reports are automatically saved to my desktop folder in pdf format.
I can get to output pdf but have to manually save into the folder for each report.
The code I had written isn't saving at all.... where am I going wrong with this code:


Private Sub Command127_Click()

On Error Resume Next

DoCmd.OutputTo acOutputReport, "rptPrnAuto", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf"

DoCmd.OutputTo acOutputReport, "rptPrnCyto", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf"

DoCmd.OutputTo acOutputReport, "rptPrnLAD", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf"

DoCmd.OutputTo acOutputReport, "rptPrnMolecular", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf"

DoCmd.OutputTo acOutputReport, "rptPrnnonRICNK69", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf"

DoCmd.OutputTo acOutputReport, "rptPrnRICNK69", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf"

DoCmd.OutputTo acOutputReport, "rptPrnSubsets", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf"

DoCmd.OutputTo acOutputReport, "rptPrnTH1TH2", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf"

Err.Clear

End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:04
Joined
May 7, 2009
Messages
16,504
there are many report but saving on 1 pdf file.
 

Sreemike

Registered User.
Local time
Today, 09:04
Joined
Jan 20, 2012
Messages
31
Yes. Unique name solves the problem. The new code is as follows:

Private Sub Command127_Click()

On Error Resume Next
DoCmd.OutputTo acOutputReport, "rptPrnAuto", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf\AutoAb.PDF"
DoCmd.OutputTo acOutputReport, "rptPrnCyto", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf\CustomersCytotoxicity.PDF"
DoCmd.OutputTo acOutputReport, "rptPrnLAD", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf\LAD.PDF "
DoCmd.OutputTo acOutputReport, "rptPrnMolecular", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf\Molecular.PDF "
DoCmd.OutputTo acOutputReport, "rptPrnnonRICNK69", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf\NK69.PDF "
DoCmd.OutputTo acOutputReport, "rptPrnRICNK69", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf\RICNK69.PDF "
DoCmd.OutputTo acOutputReport, "rptPrnSubsets", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf\Subsets.PDF "
DoCmd.OutputTo acOutputReport, "rptPrnTH1TH2", acFormatPDF, "C:\Users\sreem\Desktop\RIC_RptToPdf\TH1TH2.PDF "

Err.Clear
End Sub


Is there any way I can automatically assign the surname field on the report to the pdf output name; eg: AutoAb_SMITH for the first one?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:04
Joined
Oct 29, 2018
Messages
19,019
Try:
Code:
"C:\Users\...\AutoAb_" & [Surname] & ".pdf"
 

Sreemike

Registered User.
Local time
Today, 09:04
Joined
Jan 20, 2012
Messages
31
Try:
Code:
"C:\Users\...\AutoAb_" & [Surname] & ".pdf"
The surname will be patient's surname. Each report is based on an individual query. Is there anyway saving the pdf of report with the surname of the patient automatically filled in.... eg: If patient's surname is Trump, then save this report pdf as Trump****.pdf?
 

Users who are viewing this thread

Top Bottom