@templeowls,
Did you study the DoCmd.OutputTo command syntax? It took me a while to understand what was happening (it was a few years ago).
I've cut out the non-necessary lines in your sub for this explanation.
Code:
Private Sub btnExportReport_Click()
reportName = "rptCustomerID"
1 DoCmd.OpenReport reportName, acViewPreview, , acHidden
2 DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, filename
DoCmd.Close acReport, reportName, acSaveNo
End Sub
Line 1 - opens the report named "rptCustomerID" hidden. This report is now the active object. Apparently the Report has a parameter query as the report record source, which prompts for the Customer ID.
Line 2 - the Output command - since you have the ObjectName paraneter as "reportName", the Output command re-opens the same report, resulting in the parameter request of the Customer ID (again).
What worked for me is leaving the ObjectName blank as below.
Code:
Private Sub btnExportReport_Click()
reportName = "rptCustomerID"
DoCmd.OpenReport reportName, acViewPreview, , acHidden
'OutputTo(ObjectType, ObjectName, OutputFormat, OutputFile
DoCmd.OutputTo acOutputReport, , acFormatPDF, filename '<<-- ObjectName parameter is blank
DoCmd.Close acReport, reportName
End Sub
From Help: ObjectName parameter - A string expression that's the valid name of an object of the type selected by the ObjectType argument. If you want to output the active object, specify the object's type for the ObjectType argument and leave this argument blank
Also......
Code:
DoCmd.Close acReport, reportName
The ", acSaveNo" is not needed - it for saving programmatic changes to the design of the object (in this case the report).
Hope I am clear in my explanation....