Save to PDF without opening

xyba

Registered User.
Local time
Today, 18:20
Joined
Jan 28, 2016
Messages
189
Hi

I have the below code to save a report to pdf. However, I don't want the report to open so could someone suggest what I need to change in the code, please:

Code:
Private Sub CreateReportBtn_Click()
On Error GoTo cmdPrintMapArea1_Click_Err
DoCmd.OpenReport Me.RepNameBox, acViewReport, , IIf(Me.DepNameBox = "All", "", "dept='" & Me.DepNameBox & "'")
DoCmd.OutputTo acOutputReport, , acFormatPDF
DoCmd.Close acReport, Me.RepNameBox

Exit Sub
 
you can open the report as Hidden:
Code:
DoCmd.OpenReport Me.RepNameBox, acViewReport, , _
IIf(Me.DepNameBox = "All", "", "dept='" & Me.DepNameBox & "'"), acHidden
 
you can open the report as Hidden:
Code:
DoCmd.OpenReport Me.RepNameBox, acViewReport, , _
IIf(Me.DepNameBox = "All", "", "dept='" & Me.DepNameBox & "'"), acHidden

Hi arnel

I tried adding acHidden as you suggested but this also seems to hide the save dialog box. As there is no default "save to" filepath this needs to be selected by the user.
 
the button click was from the Form?
then add another textbox to that form where to save the report.
 

Users who are viewing this thread

Back
Top Bottom