Pop-up message when converting Access report to PDF

The problem for me is that it apparently can't be cancelled
But that's the point, isn't it?
The main problem with the printing dialog, at least for me, is that it allows the user to intentionally or accidentally cancel the generation of the PDF. Hiding the dialog primarily prevents the user from cancelling the process. This is a feature, not a bug!
 
Obviously not a bug. As to whether it’s beneficial will depend on circumstances.
For example, I had a report of well over 1000 pages which takes a very long time to print to PDF and can cause Access to hang. In such cases, being able to cancel is a necessity
 
I've tried Edgar's solution and it seems fine to me.
However, compared to:
DoCmd.SetWarnings False
'Code
DoCmd.SetWarnings True
Which is quite "clean," it doesn't seem like the definitive solution.
Still, Edgar's work is appreciated.
Best regards.
There is a fundamental difference.
Edgar's code works whereas using DoCmd.SetWarnings False doesn't have any effect in this context
 
That's right, Collin.
I mentioned it as a "comparative," understanding that each code has its own scope of application.
Regards.
 
Thanks for the testing, Colin

Here's another approach, it also hangs the Access app if the report is too big but, in return, it won't show any dialog because it runs in another instance as I was previously hinting.

The code looks like this:
Code:
Option Compare Database
Option Explicit

Sub outputReportAnotherInstance()
    Dim targetPath As String
    targetPath = CurrentProject.Path & "\deletethis" & Format(Now(), "ddmmyyyyhhmmss") & ".pdf"
    DoCmd.OutputTo acOutputReport, "report1", acFormatPDF, targetPath
End Sub

Public Sub externallyPrint()
    With CreateObject("Access.Application")
        .OpenCurrentDatabase CurrentProject.FullName
        .Run "outputReportAnotherInstance"
        .Quit
    End With
End Sub

And from the calling form:
Code:
Private Sub Comando0_Click()
    Me.Comando0.Caption = "hold on..."
    externallyPrint
    Me.Comando0.Caption = "external print"
End Sub

You can then add whatever you need. I'm just giving ideas.

Note: The report's output folder is the same as the app in this version...
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom