AndyAinscow
asked on
Strange problem with exporting access report in pdf format
Access 2013 (accdb format) database.
I have to following code to open an access report in preview, export to pdf and then close the report (the szWhere is a filter string):
In development it works perfectly. In the production environment this code has stopped working. It has been working for ca 18 months without problem. It fails on the OutputTo line.
Interestingly on the production PC if a report is opened in preview mode manually, then the export to pdf/xps option chosen the report is exported without problem.
I'm stuck - the functionality works when run manually but not automatically. Any ideas as to what the problem could be and how to get it working again.
I have to following code to open an access report in preview, export to pdf and then close the report (the szWhere is a filter string):
'Preview the report
DoCmd.OpenReport szDocName, acViewPreview, , szWhere
'*****************************************************************************************
DoCmd.OutputTo acOutputReport, , acFormatPDF, szFileName, False
'*****************************************************************************************
DoCmd.Close acReport, szDocName
In development it works perfectly. In the production environment this code has stopped working. It has been working for ca 18 months without problem. It fails on the OutputTo line.
Interestingly on the production PC if a report is opened in preview mode manually, then the export to pdf/xps option chosen the report is exported without problem.
I'm stuck - the functionality works when run manually but not automatically. Any ideas as to what the problem could be and how to get it working again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I had this recurring problem before and prevented it from happening by adding codes to check if the folder exists and if it don't exists, create the folder before running the codes.
ASKER
Missing folder.
Open in new window