I need to capture the printing of a report, not just the preview. Is there a
trap similar to On Print (which occurs on preview) that I can use?
The user previews the report but if he doesn't print it I don't want the
event to fire.
You can use the Report's Activate event (which only fires when the
report is Previewed) to determine if the report is sent to the
printer.
The actual starting value of intPreview depends upon if you have a
control in the report to compute [pages].
Option Compare Database
Option Explicit
Dim intPreview As Integer
==============
Private Sub Report_Activate()
intPreview = -1 ' If [Pages] is not used
' intPreview = -2 ' If [Pages] used
End Sub
=========
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
If intPreview >= 0 Then ' If [Pages] not used
' If intPreview >= 1 Then ' If [Pages] used
MsgBox "Gone Printing"
End If
intPreview = intPreview + 1
End Sub
I used it to alter the report when/if actually printed:
For example, in the Detail Print event.....
If intPreview = 0 Then
' Do something here, etc.
End If
Note: While this code will let you know if the report was sent to the
printer, there is no absolute method of determining if the report was
successfully printed without actually having the pages in hand.
Printers do run out of paper and ink, etc.