I have the below code that actually works and prints the reports, just not in my chosen folder.
Data...
ReportName: Invoice Summary
FolderPath: S:\Order Imports\Electronics\Reports\
FileNam: Invoice Summary 646969 101319-101919.pdf
I'm expecting the PDF to land in:
S:\Order Imports\Electronics\Reports\Invoice Summary 646969 101319-101919.pdf
However, it's landing in the same folder as my database:
S:\Databases\Invoice Summary 646969 101319-101919.pdf
Is there something obvious I'm doing wrong?
How can I print to the intermediate window so I can see what's happening?
Code:
Public Function PrintReports()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim varQuery As String
Dim varReportName As String
Dim varFolderPath As String
Dim varFileNam As String
varQuery = "qry_Reports_Print"
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT ReportName, FolderPath, FileNam FROM " & varQuery, dbOpenSnapshot)
Do While Not rs.EOF
varReportName = rs("ReportName")
varFolderPath = rs("FolderPath")
varFileNam = rs("FileNam")
'acViewPreview = Print Preview, acViewReport = Direct to Printer
DoCmd.OpenReport varReportName, acViewPreview, , "'" & varFolderPath & "'"
DoCmd.OutputTo acOutputReport, "", acFormatPDF, varFileNam
DoCmd.Close acReport, varReportName
DoEvents
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
thanks!