event for print rather than preview

J

John F

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.
 
F

fredg

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.
 
N

NJS

Hi fred,
When I implement this the detail-print event fires upon preview, but not on
print?
Am I doing something wrong.
cheers.
 
G

Guy Kerr

I had a similar problem which baffled me since other reports where using the
same code successfully.

In my case it was something to do with the combination of the form that had
the button that invoked the print preview was set to POPUP mode and the
report itself being set to POPUP also. Somehow this wouln't allow the On
Activate or On Deactivate code to run.

I ended up leaving the calling form as POPUP but turning POPUP and MODAL off
on the subsequent report and the code included in this thread worked as
expected.

Guy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top