A family of Microsoft relational database management systems designed for ease of use.
Sure. There was not a problem with the code but a problem with the data being used by one of the queries be accessed by the code.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have some code that generates a report unique to each grower that outputs the report as a PDF document to a unique folder based on the grower's name. It has been working fine for years and is till working fine....somewhat. For some reason it works great for every grower but one. It works perfect for the grower before and after the one the problem occurs with. When it goes to do the output for the one grower I get the following error message:
Error - 2501 : The OutputTo action was canceled.
The code is listed below and the line throwing the error message is in bold.
As you can see I have added some debug.print statements to try in help in figuring out the problem.
Can anyone shed any light on what might be going wrong with this one grower?
Code:
Sub SaveRptPDF(stRptName As String, stPathPdfName As String)
On Error GoTo ErrorHandler
'Form Name - Procedure Name
strProdName = "modEmailReports -> SaveRptPDF"
Debug.Print "stRptName: " & stRptName
Debug.Print "stPathpdfName: " & stPathPdfName & vbCrLf & vbCrLf
'DoCmd.OpenReport "rptIntakeGrowerStatements", acViewPreview
'save report as PDF
**DoCmd.OutputTo acOutputReport, stRptName, acFormatPDF, stPathPdfName, False**
If stPathPdfName = "K:\Grower Portal\EISSES\_FARMS\_LTD\Pool\Defects\2021\_Defect\_Report\_Grower.Pdf" Then
stPathPdfName = "K:\Grower Portal\EISSES\_FARMS\_LTD\Pool\Defects\2021\_Defect\_Report\_Grower.xls"
DoCmd.OutputTo acOutputReport, stRptName, acFormatXLS, stPathPdfName, False
End If
ExitProdcedure:
Exit Sub
ErrorHandler:
MsgBox "Error: " & strProdName & " - " & Err.Number & " : " & Err.Description & " Please record this message and contact IT.", vbOKOnly + vbInformation
Resume ExitProdcedure
On Error GoTo ErrorHandler
End Sub
A family of Microsoft relational database management systems designed for ease of use.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Sure. There was not a problem with the code but a problem with the data being used by one of the queries be accessed by the code.
For the benefit of the community, can you please share the solution?
Thanks for the suggestion. I appreciate the assistance.
I found the problem and it has been corrected.
What are the debug.prints?
Are there any special characters in the path?