Why messagebox appears then closes on successful run of DoCmd.OutputTo....pdf

essaytee

Need a good one-liner.
Local time
Tomorrow, 09:56
Joined
Oct 20, 2008
Messages
540
I am successfully printing a report directly to pdf via the command,
Code:
DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, strFile, False

Everytime I run the code there is a messagebox that appears and instantly disappears, though I can't read the contents of the messagebox. This happens whether the pdf file to be saved exists or not. On debug it happens on entering the 'Docmd.OutputTo' line and still can't trap the messagebox so at least I could read it. Even with
Code:
Application.Echo false
at the start of the code snippet does not prevent the messagebox from appearing.

The below is my code snippet directly from the click event of a button. Any advice appreciated.

Code:
Private Sub cmd_PDF_Print_Click()
On Error GoTo Error_In_Code
    
    Dim strReport As String
    Dim strMsg As String
    Dim strFolder As String
    Dim strFileName As String
    Dim strFile As String
    
    If IsNull(Me.cbo_Week_Ending) Then
        strMsg = "A Week Ending date is required"
        MsgBox strMsg
    Else
        Application.Echo False
        strReport = "rpt_Week_Distance_all"
        ' this folder name will be retrieved via a Open File Dialog box
        strFolder = "F:\OneDrive\Documents\Exercise\AccessPrint\"
         ' will have switch here, depending on report, will dictate the output filename
        strFileName = "ThisWeek-Distance.pdf"
        
        strFile = strFolder & strFileName
        DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, strFile, False
        
        Application.Echo True
    End If
    
Exit_Code:
    Exit Sub
    
Error_In_Code:
    Application.Echo True
    MsgBox "cmd_PDF_Print_Click() " & Err.Number & " " & Err.Description
    Resume Exit_Code
End Sub
 
I believe it is just a message stating the report is being run/saved. I’m not aware of a solution for hiding it. Are you concerned something is wrong?
 
I believe it is just a message stating the report is being run/saved. I’m not aware of a solution for hiding it. Are you concerned something is wrong?
Everything works, the report is saved correctly, so wasn't worried about any logic. With the messagebox appearing it did raise a doubt that something might not be right. So, if that is the case, I can remove the Application.Echo commands.
 
I have been working on a process to generate single page reports to be emailed. Does the exact same thing. I've been able to see enough to know it is showing what is being printed. Try putting a few big graphics on for testing. You should see the message longer.
 
There is a reporting process in the Northwind Developers template that does the same.
 
A little research shows this is done by the print driver generating the PDF. It is intended to let a user know the PDF is actually being printed and how far along in printing it is. For a single page, you would expect it to pop up and go away almost immediately. For a 100 page document with lots of images, you could see it for a couple minutes. Normally it also tells you which page it is on.
 

Users who are viewing this thread

Back
Top Bottom