Reporting to PDF

Stemdriller

Registered User.
Local time
Today, 23:19
Joined
May 29, 2008
Messages
187
Try to get a report to save to PDF with Access 2007

Using the code below but it is erroring

DoCmd.OutputTo acOutputReport, "rptMAINREPORT", "PDF Format (*.pdf)", "C:/Transfer/" & PDFLink _
& ".pdf", False


The report I am trying to save as PDF is rptMAINREPORT and within that report is a textbox called PDFLink which has the contract number in.

So I am trying to save the Document as ContractNumber.pdf in a folder called Transfer on C.

Any ideas

Thanks
 
This: "PDF Format (*.pdf)"

Should be this: acFormatpdf

No quotes by the way
 
Thanks for responding

So I have amended to thus

DoCmd.OutputTo acOutputReport, "rptMAINREPORT", acFormatPDF, "C:/Transfer/" & PDFLink _
& ".pdf", False

Getting 'Run Time Error 2501' The Output to action was cancelled????
 
File paths use a backslash "\" not the forward slash "/"
 
Thanks for responding

So I have amended to thus

DoCmd.OutputTo acOutputReport, "rptMAINREPORT", acFormatPDF, "C:/Transfer/" & PDFLink _
& ".pdf", False

Getting 'Run Time Error 2501' The Output to action was cancelled????

No need to truncate this little line...

Code:
DoCmd.OutputTo acOutputReport, "rptMAINREPORT", acFormatPDF, "C:\Transfer\" & PDFLink & ".pdf", False
 
Thanks for the responses

Still not happening.

I get the little window telling me it is starting, then the Run Time window comes up

I believe it is the way in which 'PDFLink' gets it value. If I change the line to

DoCmd.OutputTo acOutputReport, "rptMAINREPORT", acFormatPDF, "C:\Transfer\" & "Test" & ".pdf", False

Then a file called %20test.pdf gets produced.

If I wanted the PDF to be called the Sales Number from a form that is currently open, (frm_ContractHeader!SALESORDER) how could I incorporate that into the command line DoCmd.Output etc?
 
It would be:


DoCmd.OutputTo acOutputReport, "rptMAINREPORT", acFormatPDF, "C:\Transfer\" & Forms!frm_ContractHeader.SALESORDER & ".pdf", False
 
Bob,

You are a Saint. Many Many thanks

vbInet, also many thanks

Best Regards

Gareth
 
Glad you got that working :D

By the way you would need to trap for errors if the user tries to save a report with the same file name twice.
 
Glad you got that working :D

By the way you would need to trap for errors if the user tries to save a report with the same file name twice.

I would test if the file already exists and then Kill it before saving the report file.
 
FYI : My Access users run via Citrix -
So, I preview the report to them via citrix. When they close the report, they have an option to save the report (from a Citrix network drive) to the location of thier choice (i.e. a shared drive in their regional office).
This requires the Adobe reader to be installed on the server.
Testing this from my development workstation, deploying to a Citrix test server next week. Bob Larson deserves a lot of thanks for the help.

Code:
Private Sub Report_Deactivate()
Dim MyFiLeName      As String
    If Not NoData Then  ' checks for no data event to prevent a mis fire
        DoEvents
        MyFiLeName = "C:\Standard_Report " & Format(Now, "mm-dd-yyyy hhnnss") & ".pdf"
        DoEvents
        MsgBox "Please Save Your Adobe File to a network file location", vbOKOnly, "Save Now or loose it"
        DoEvents
        'DoCmd.OutputTo acOutputReport, "Rx_ReportNewAPD", acFormatPDF, MyFiLeName, True ' , , , acExportQualityPrint
        DoCmd.OutputTo acOutputReport, "rptAPD_2010", acFormatPDF, MyFiLeName, True
        ' The Now function just time stamps the file so all files are unique in name on citrix server for a user to save
        DoEvents
    End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom