trapping toolbar print event

N

NJS

Good day all.
does anyone know how to trap the toolbar print event, so that I can trigger
a logging function every time the report is printed.
All the report/print functions appear to fire prior to actual printing (e.g.
during print preview). I need to only log the event when the report is on its
way to the printer.
thanks in advance.
 
T

Tom van Stiphout

On Tue, 22 Apr 2008 20:56:10 -0700, NJS

And how would you know that the report printed successfully? Perhaps
there was no paper in the printer. Perhaps someone reset it and the
byte stream was lost.
Answer: you can't know.
THerefore: you ask the user: Did it print correctly?

-Tom.
 
N

NJS

I'm not sure if your answer is related to my question or someone else but, I
need to trap the event (Access/system) that fires when the user presses the
print icon.
fredg posted a useful response on 29/6, but when I implement this the
detail-print event fires upon preview, but not on print?
 
T

Tom van Stiphout

On Wed, 23 Apr 2008 08:30:02 -0700, NJS

We may not be on the same wavelength. In most cases people are not
interested in if a toolbar button was clicked or not, but rather in
the end result (a report was printed, and we can later say "look, on
<date> you successfully printed the report, so don't complain now").

My point was that it is impossible (or at least exceedingly difficult)
for Access to figure out if the report printed successfully. Therefor
such implementations typically ask the user: MsgBox("Did it print?",
vbYesNo or vbQuestion)

There is no event that fires when a standard toolbar button is
clicked. So the only thing you have to work with is my solution above,
or any of the report's events. As you found out, it is hard (I think
impossible) to know if the report was previewed or printed. To Access
that's just a minor change in destination, and the events fire the
same way.

One possible workaround: use a form to run the report from. Provide
two buttons: Preview, and Print. Hide and/or secure the report object
itself so users can't invoke it manually, but only through your form.

-Tom.
 
N

NJS

Thanks Tom,
I believe we are on the same page.
My client needs to know when a user invokes a print, not necessarily whether
it was successful or not.
I was hoping for a Windows API/ystem solution - still looking,
cheers,
 
J

John Spencer

Here is a response I found from an old posting by FredG.

You can use the following code to determine if the report has been sent to the
printer, whether or not it has also been previewed.

HOWEVER... Even if it has been sent to the printer, there is no way to tell if
the printout has been successfully printed until you have the paper report in
your hand.

The actual starting value of intPreview below depends upon if you have a
control in the report to compute [pages].

Comment out the un-needed portion of the code accordingly.


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"
' You can place code here to update a table field to show it was
sent to printer
End If
intPreview = intPreview + 1
End Sub
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
N

NJS

Thanks John.
I actually referred to this earlier in this thread - (>>> fredg posted a
useful response on 29/6, but when I implement this the)
If I cannot get a more positive approach I will experiment some more with
this.

cheers.

John Spencer said:
Here is a response I found from an old posting by FredG.

You can use the following code to determine if the report has been sent to the
printer, whether or not it has also been previewed.

HOWEVER... Even if it has been sent to the printer, there is no way to tell if
the printout has been successfully printed until you have the paper report in
your hand.

The actual starting value of intPreview below depends upon if you have a
control in the report to compute [pages].

Comment out the un-needed portion of the code accordingly.


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"
' You can place code here to update a table field to show it was
sent to printer
End If
intPreview = intPreview + 1
End Sub
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
Thanks Tom,
I believe we are on the same page.
My client needs to know when a user invokes a print, not necessarily whether
it was successful or not.
I was hoping for a Windows API/ystem solution - still looking,
cheers,
 

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