Error 2501 Outputto action cancelled
When trying to use the "Docmd.OutputTo" command in Access to export a report to a PDF file, we started getting error 2501, Outputto Action Cancelled.
The code seems to be really picky. If you Google this error message, you get all kinds of suggestions. This is what worked for us:
Dim ReportName As String
ReportName = "rptPrefundExceptions"
DoCmd.OpenReport ReportName, acViewPreview, , "LoanID=" & Me.LoanID
DoCmd.SelectObject acReport, ReportName
DoCmd.OutputTo acOutputReport, ReportName, acFormatPDF, CalculateFileLocation & ReportName & ".pdf", 0, , , acExportQualityPrint
DoEvents
Note: calculatefilelocation is a subroutine that dynamically calculates the right folder for each customer associated with the report.