I used this thread:
MS Access auto/scheduled report export. | MrExcel Message Board
to learn how to schedule a report to be exported to a pdf file once per day. I have the report working, the macro works, and the batch file runs at the appropriate time. I actually set it up as the 'AutoExec' macro for this .accdb file and the vba code closes the database file. This report is the only thing done with this database file.
This works when I run the code directly from the VBA editor. It also works when I run the macro. However, when I simply open the database file (or it's automatically opened by the task scheduler), the second page of the pdf that gets exported looks like this:
If you notice, the page count says '2 of 3'. However, the pdf only has 2 pages.
Any idea why this might happen/what a solution might be? I can run this manually and it works just fine, but the goal was to have this report run from a remote machine automatically.
MS Access auto/scheduled report export. | MrExcel Message Board
to learn how to schedule a report to be exported to a pdf file once per day. I have the report working, the macro works, and the batch file runs at the appropriate time. I actually set it up as the 'AutoExec' macro for this .accdb file and the vba code closes the database file. This report is the only thing done with this database file.
VBA Code:
Public Function Report_Export()
'Creating two filename variables so they are easier to reference and modify in the future if necessary.
Dim FileNamePDF As String
FileNamePDF = "Filenamegoeshere.pdf" 'This is a network drive link
DoCmd.OutputTo acOutputReport, "CADTech Finishing Detail Report", acFormatPDF, FileNamePDF, False, "", , acExportQualityPrint
Application.Quit
End Function
This works when I run the code directly from the VBA editor. It also works when I run the macro. However, when I simply open the database file (or it's automatically opened by the task scheduler), the second page of the pdf that gets exported looks like this:
If you notice, the page count says '2 of 3'. However, the pdf only has 2 pages.
Any idea why this might happen/what a solution might be? I can run this manually and it works just fine, but the goal was to have this report run from a remote machine automatically.