I have a DB that is set to open to a specific form. This part works. One of the Command buttons on the Form outputs 4 reports to my C: drive into a Folder. Three of these "EOC", "1097A", and "PTEAR B rpt" always work.
The fourth, "CLEAR", is failing with "Run-Time Error 2046. The command or action 'OutputTo' isn't available now.
The code outputs the reports in this order: EOC, 1087A, CLEAR, PTEAR. I have moved the order around but the CLEAR is the only one that fails.
When it fails I check the report and it looks good and has the correct information.
Here is the code:
Now for the trick. If I open the DB using the shift key and then open the form and click the same command button, everything works fine. Only when I open the DB with a double click does the error occur.
I don't under stand why opening the DB normally shows this problem and opening it with the SHIFT allows it to run correctly.
Help please,
John
The fourth, "CLEAR", is failing with "Run-Time Error 2046. The command or action 'OutputTo' isn't available now.
The code outputs the reports in this order: EOC, 1087A, CLEAR, PTEAR. I have moved the order around but the CLEAR is the only one that fails.
When it fails I check the report and it looks good and has the correct information.
Here is the code:
Code:
Private Sub PrepForms_Click()
DoCmd.Hourglass (HourglasOn)
'DoCmd.Echo (EchoOff)
'DoCmd.SetWarnings (Off)
fileName = "EOC" 'filename for PDF file*
fldrPath = "C:\TempEmail"
filePath = fldrPath & "\" & fileName & ".pdf"
DoCmd.OutputTo acReport, "EOC Sheet rpt", acFormatPDF, filePath, False
fileName = "1087A"
filePath = fldrPath & "\" & fileName & ".pdf"
DoCmd.OutputTo acReport, "1087A rpt", acFormatPDF, filePath, False
fileName = "CLEAR"
filePath = fldrPath & "\" & fileName & ".pdf"
'DoCmd.OutputTo acReport, "CLEAR rpt", acFormatPDF, filePath, False
[highlight #FCE94F]DoCmd.OutputTo acReport, "CLEAR rpt", acFormatPDF, filePath, False[/highlight]
fileName = "PTEAR Form"
filePath = fldrPath & "\" & fileName & ".pdf"
DoCmd.OutputTo acReport, "PTEAR B rpt", acFormatPDF, filePath, False
'DoCmd.Echo (EchoOn)
DoCmd.Hourglass (HourglassOff)
'DoCmd.SetWarnings (WarningsOn)
MsgBox "All Forms have been prepared. Please select the first instructor."
Me.EmailDD.Enabled = True
End Sub
Now for the trick. If I open the DB using the shift key and then open the form and click the same command button, everything works fine. Only when I open the DB with a double click does the error occur.
I don't under stand why opening the DB normally shows this problem and opening it with the SHIFT allows it to run correctly.
Help please,
John