How can I know if the report was completed?
I have a situation where I have to store the number of pages that a
particular report uses each month. I am trying to use the
"AbsolutePageCount" property when the user exits the report.
However, when the report is displayed in the preview and the user exits
without printing or without displaying the last page, the
"AbsolutePageCount" property is not correct.
I would need to do one of two things:
1) Force the generation on the entire report upon preview. (Make sure
all pages are generated)
2) On exiting the report preview, check if the entire report was
generated (completed), and if true, then store the ""AbsolutePageCount".
Thanks in advance,
Jay
particular report uses each month. I am trying to use the
"AbsolutePageCount" property when the user exits the report.
However, when the report is displayed in the preview and the user exits
without printing or without displaying the last page, the
"AbsolutePageCount" property is not correct.
I would need to do one of two things:
1) Force the generation on the entire report upon preview. (Make sure
all pages are generated)
2) On exiting the report preview, check if the entire report was
generated (completed), and if true, then store the ""AbsolutePageCount".
Thanks in advance,
Jay
This discussion has been closed.
Comments
--
Ed Dressel
Team DM
For the time being, I am doing the following:
1) Define a variable "IsEndReport" as Boolean in the Form.
2) Before generating the report, Assign False to "IsEndReport".
3) Define events "OnEndFirstPass" and "OnEndSecondPass" where I set the
variable "IsEndReport" to True, depending if the report is a onepass or
a twopass report.
4) After previewing the repot, I check the "IsEndReport" variable.
Is there a simpler way to accomplish this?
Regards,
Jay
If you have your report set to be a two pass report, the AbsolutePageCount
should already be calculated. Inside an early event such as the StartPage
you can first check the pass then find the AbsolutePageCount.
if ppReport.SecondPass then
TotalPagesUsed := TotalPagesUsed + ppReport.AbsolutePageCount;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico,
That only works if the report is a two pass report, and it implies using
events WITHIN the report. What is most desired is to be able to
determine this WITHOUT having to depend on using events during the
report process. Something like this in the delphi code.
ppReport1.Print;
if ppReport.ReportCompleted then
do something;
No dependencies of events within the report.
This brings me to another important cuestion with regards to events,
RAP, and template reports.
What is my experience, (maybe I'm wrong), if I use a Report compontent
"pRep" in my delphi form and put events (like the ones I mentioned
before) in the delphi code, these are not fired if I load a report
Template. I suppose that when a template is loaded, it DISREGARDS any
events that were defined in delphi and uses any events defined in the
template.
If I want to force the use of the events defined in delphi, I load the
template FIRST, and AFTER the template is loaded, I redefine de delphi
events such as:
pRep.OnEndFirstPass := pRepEndFirstPass;
So far so good, but what happens if the template has this same event
coded in its RAP?. Are both events used? if so, which one first? if not,
Which on is used?
I suppose that in this case, the delphi code would be used REPLACING the
templates code. If this is so, then it implies that whatever events MUST
be used in delphi code CAN NOT (or should not) be used in the template.
So far this has not happened, but it sure is a potencial disaster to
happen at some point.
So far I have had 2 situations in which I MUST put code in delphi to do
things right and MUST impose a limit in the use of events in the
templates RAP code.
It would be great if ReportBuilder could be enhanced in such a way that
this could be avoided. In my personal opinion, there are a few
properties, events and procedures that could (should) be added to the
product to avoid having to do tricks and workarounds to make things work
more naturally.
I also want to say that ReportBuilder is GREAT PRODUCT, the entire
concept is FANTASTIC. It only lacks a few key properties to make it more
flexible to work with.
Regards
Jay
Forgive me if I'm on the wrong track.
Since the preview form is modal, the report will by definition have
completed before any code after the Report.Print call is executed. If
however you need to keep track of the amount of pages in the report that was
just printed, you will need to use some internal report events (and a two
pass report if you would like to know the total number of pages regardless
what your user does). Once the report has finished printing, there is no
way to access information about the generated report.
If a RAP event and a Delphi event are assigned, both events will fire. The
order will be determined by where each is defined in the RBuilder source.
It is never good practice to purposefully code both events as it may cause
issues down the line.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Hmm, currently suffering a very similar situation:
I need to know if a Report has been printed or if someone
pressed either Cancel on the preview dialog or cancel on the printer
selection dialog....
I was just trying to code an event handler for the
OnPrintingComplete event but it doesnt fire, maybe because
i am loading the report from template ?
Tnx,
Wolfgang
--- posted by geoForum on http://delphi.newswhat.com
If you are loading templates, you will either need to define your events
inside the template (i.e. RAP) or you will need to assign your events after
the template is loaded. Below are a few articles that may be of some help.
--------------------------------------------
Article: Troubleshooting Lost Event Handlers
--------------------------------------------
Let's assume you have created a report in Delphi and assign an event
handlers to the OnPreviewFormCreate event of the report. The event is
generated by Delphi as:
procedure TForm1.ppReport1PreviewFormCreate(Sender: TObject);
You then save the report to an RTM file 'Report1.RTM.' The events are
stored as references only, and so the RTM contains:
object ppReport1: TppReport
.
.
OnPreviewFormCreate = ppReport1PreviewFormCreate
end
You then go on to work on a different report. Saving it with under then
name 'Report2.RTM'. Only this time, before you save the report you
change the report component name to: rptOrders. Delphi automatically
updates the event declaration for OnPreviewFormCreate event to:
procedure TForm1.rptOrdersPreviewFormCreate(Sender: TObject);
You then create two buttons on the form, one to load Report1 and
preview, the other to load Report2 and preview. When you run the app
and click Report1, you an error. This is because the Report1.RTM file
contains a reference to ppReport1PreviewFormCreate, a method which no
longer exists (at least with this name) in the form.
One answer is to load all your rtm files into the report component you
will be using for loading. Fix any errors, reassign any events that get
cleared. This will update your rtms to contain the proper event handler
names.
------------------------------------------
Tech Tip: Detecting whether Report was
Printed to the Printer
------------------------------------------
The Report.AfterPrint event can be used to
determine whether the report was printed
to the printer (rather than preview, ...).
Example:
procedure TForm1.ppReport1AfterPrint(Sender: TObject);
begin
if (ppReport1.PrinterDevice <> nil) then
ShowMessage('Report was printed to the printer');
end;
Note: If the user cancels the report while it
is running, then the Report.OnCancel event will
fire, followed by the Report.AfterPrint event.
Example:
procedure TForm1.ppReport1Cancel(Sender: TObject);
begin
ShowMessage('Printing cancelled by user');
end;
------------------------------------------
Tech Tip: Detecting whether PrintDialog's
Cancel button was Selected
------------------------------------------
When the print dialog is displayed to the
user, you can determine whether the Cancel
button was selected by using the
Report.OnPrintDialogClose event.
Example:
procedure TForm1.ppReport1PrintDialogClose(Sender: TObject);
begin
if ppReport1.PrintDialog.ModalResult = mrCancel then
ShowMessage('Use chose to cancel the print request');
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com