I seem to get an intermittent problem when trying to output access reports to PDF, resulting in the error 2501.
This has been covered numerous times on the internet but the fault usually seems to lie with either characters in the file name such as brackets and colons or permissions, neither of which seem to apply to me.
When I say the problem is intermittent, it happens on certain records and not others, rather than sometime I can output a report with record 'a', and other times I can't.
Something else is is how I output the report. The error happens when I click on a command button on a form using this code:
However, I have another button on the form to just view the report, using:
If I right click on the report, and then print to PDF using the Microsoft to PDF printer, I don't get the error message, even on a record where I would normally get it using the outputto function.
During testing, it doesn't matter what I name the file or where I save it to, I still get the error.
Any ideas what may be causing the issue?
This has been covered numerous times on the internet but the fault usually seems to lie with either characters in the file name such as brackets and colons or permissions, neither of which seem to apply to me.
When I say the problem is intermittent, it happens on certain records and not others, rather than sometime I can output a report with record 'a', and other times I can't.
Something else is is how I output the report. The error happens when I click on a command button on a form using this code:
Code:
DoCmd.OpenReport stDocName, acViewPreview, , "Job_Reference = " & Me.Job_Reference
DoCmd.OutputTo acReport, stDocName, acFormatPDF
DoCmd.Close acReport, stDocName
However, I have another button on the form to just view the report, using:
Code:
DoCmd.OpenReport stDocName, acViewPreview, , "Job_Reference = " & Me.Job_Reference
During testing, it doesn't matter what I name the file or where I save it to, I still get the error.
Any ideas what may be causing the issue?