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,
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
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:
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
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