Determine if a report is REALLY printing

J

Jasonm

Good evening all! I have a problem that I cannot seem to find a way around.
(Isn't that always the case here!) I want to be able to set a bit in my db
if a record has run in a report and has actually printed. I have created the
code that is marking the record as I desire, but it does if even if the page
is only previewed!

I was thinking (wrongly it seems now) that the on print event would only
fire if the report was actually sent to the printer... But it seems that it
fires when the report is written to the screen.

Does anyone have any suggestions as to how I should acomplish this? The only
thing that I can think of right off the top of my head would be to have a
report for previewing, and a report for printing, but I see problems with
that... If the user printed the preview report the records would not get
marked.

Thanks in advance for your assistance.
Jasonm
 
A

Allen Browne

Hi Jason.

There's not a simple answer to this, so it will require a bit of lateral
thinking.

Thinking backwards, if the report is not previewed on screen, its Activate
event does not fire. You can therefore examine whether the report is going
straight to the printer by creating a module-level boolean variable, setting
it to True in the Activate event, and testing it later. But this all falls
apart if the user previews the report and prints from the toolbar, because
the preview does trigger Activate.

Thinking sideways, another approach is create a batch number for the print
run, and assign the records to it before running the report. The report is
filtered to just this batch. This means you can reprint the batch at any
time (really useful after a paper jam), undo the batch and redo it if
something wasn't right (e.g. an entry was missed), and keep track of when
the record was first printed.

It's quite simple. You need a table to record the batch, with fields:
BatchID primary key
BatchCreateDate date/time
ReportName Text (which report)

Now you write code to AddNew to the batch table, and get the new BatchID.
Assign this value to all the records that have never been printed and meet
the criteria for your print run. Then OpenReport using a WhereCondition that
opens just this one batch.
 
J

Jasonm

Allen, Thank you very much for your reply! After I gave up on this problem
last night I was thinking along the lines that you mentioned (I.E creating a
batch file to "remember" the files)... but it sounded a bit more complicated
that I wanted to try.

I gues that If I really want this functionality I will have to look into
something like this. I was also thinking that I may be able to identify
"where" the report was called from ( either a print button or a preview
button from the report selection form) and use conditional logic to allow
the records to be marked.

I think that I will give all these approaches a try.

Jasonm
 
F

fredg

Good evening all! I have a problem that I cannot seem to find a way around.
(Isn't that always the case here!) I want to be able to set a bit in my db
if a record has run in a report and has actually printed. I have created the
code that is marking the record as I desire, but it does if even if the page
is only previewed!

I was thinking (wrongly it seems now) that the on print event would only
fire if the report was actually sent to the printer... But it seems that it
fires when the report is written to the screen.

Does anyone have any suggestions as to how I should acomplish this? The only
thing that I can think of right off the top of my head would be to have a
report for previewing, and a report for printing, but I see problems with
that... If the user printed the preview report the records would not get
marked.

Thanks in advance for your assistance.
Jasonm

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.

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
 
A

Allen Browne

Jason, just in case you are still checking answers, there's a new web page
here that illustrates the technique:
Has the record been printed?
at:
http://allenbrowne.com/ser-72.html

There's a little sample database you can download to illustrate the
technique.
 
J

Jasonm

Allen, Thanks for the point in the correct direction. I have several
databases that I think I can use this for!

Thanks again for everyones help!

Jason
 

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