Rx_
Nothing In Moderation
- Local time
- Today, 05:46
- Joined
- Oct 22, 2009
- Messages
- 2,803
A button opens a report, the report hides and shows a user form. The user form allows several pull-down, and options to be selected, then hides while the report generates. The report is in Print Preview mode.
Goal: The Report needs to allow the user to Save As a PDF.
One more problem: It runs on Citrix, so each user must Save As and pick the shared drive for thier region.
Trying to run the DoCmd.OutputTo ... code as the last line in the Report_Open event - gets an error.
After the report is finished - the code from the debugger window does create an Access 2007 Report to PDF file on my C:\ drive.
Two part Question:
Where would be the best place to run the DoCmd.outputTo...
Is there a "save as..." option that brings up a dialogue box for the user to pick a path?
? err. Number 2585
? err.Description This action can't be carried out while processing a form or report event.
DoCmd.OutputTo acOutputReport, "rptProjectSheet", acFormatPDF, strFileNameAndPath
Works from debugger window after report is completed and previewing
DoCmd.OutputTo acOutputReport, "Rx_ReportNewAPD", acFormatPDF, "C:\Access2007TestPDF1.pdf", True, , , acExportQualityPrint
Works from debugger window after report is completed and previewing - and it opens up the report in Adobe viewer.
Searching, I found this code, but don't know if it might be useful for Access 2007
Goal: The Report needs to allow the user to Save As a PDF.
One more problem: It runs on Citrix, so each user must Save As and pick the shared drive for thier region.
Trying to run the DoCmd.OutputTo ... code as the last line in the Report_Open event - gets an error.
After the report is finished - the code from the debugger window does create an Access 2007 Report to PDF file on my C:\ drive.
Two part Question:
Where would be the best place to run the DoCmd.outputTo...
Is there a "save as..." option that brings up a dialogue box for the user to pick a path?
? err. Number 2585
? err.Description This action can't be carried out while processing a form or report event.
DoCmd.OutputTo acOutputReport, "rptProjectSheet", acFormatPDF, strFileNameAndPath
Works from debugger window after report is completed and previewing
DoCmd.OutputTo acOutputReport, "Rx_ReportNewAPD", acFormatPDF, "C:\Access2007TestPDF1.pdf", True, , , acExportQualityPrint
Works from debugger window after report is completed and previewing - and it opens up the report in Adobe viewer.
Searching, I found this code, but don't know if it might be useful for Access 2007
Code:
' Note - found this, have not tried it, it may need a PDF printer or may not be Acc 2007
Option Compare Database
Option Explicit
Function PrintToPDF(SrcFile As String)
On Error GoTo PrintToPDF_Err
'Function can be called from any report with this: "PrintToPDF(Screen.ActiveForm.Name)"
'SrcFile = name of report the function was called from, as generated by Screen.ActiveForm.Name
'DestPath = Destination path for PDF file
Dim DestPath As String
'DestFile = Destination file name for PDF file
Dim DestFile As String
'ShowPdf = launch acrobat and display saved PDF file ' Question is this PDF Reader? or full Acrobat?
Dim ShowPdf As Boolean
'Saves the file to the desktop of the current user
DestPath = "C:\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"
'Formats the file name like this: "YYYY-MM-DD-ReportNameHere.pdf"
DestFile = Year(Now) & "-" & Month(Now) & "-" & Day(Now) & "-" & SrcFile
ShowPdf = False
DoCmd.OutputTo acOutputReport, SrcFile, "PDFFormat(*.pdf)", DestPath & DestFile & ".pdf", ShowPdf, "", 0, acExportQualityPrint
PrintToPDF_Exit:
Exit Function
PrintToPDF_Err:
MsgBox Error$
Resume PrintToPDF_Exit
End Function
Last edited: