AfterGenerate event
Hi,
My report contains:
Header
Group Header
Detail
Group Footer (And a SubReport here) This is where I have my event today
Footer
I'm using the "GroupFooterBand AfterGenerate" to calculate a value to a
global variable wich later will be used in another report.
This event triggers twice if a second page is generated within the same
group. Where Should I put my calculation in order to get just one event
before a new page is generated as a result of a new group ?
Thanks
Petter
D6
RB 7
DBisam 2.12
My report contains:
Header
Group Header
Detail
Group Footer (And a SubReport here) This is where I have my event today
Footer
I'm using the "GroupFooterBand AfterGenerate" to calculate a value to a
global variable wich later will be used in another report.
This event triggers twice if a second page is generated within the same
group. Where Should I put my calculation in order to get just one event
before a new page is generated as a result of a new group ?
Thanks
Petter
D6
RB 7
DBisam 2.12
This discussion has been closed.
Comments
Perhaps this article will help....
------------------------------------------------------
Tech Tip: Calculating a Summary based on Group Totals
------------------------------------------------------
Question: I am using a Variable in the Group Footer to conditionally
calculate totals for each group. I want to add a second Variable to the
Summary that accumulates the results calculated for each group.
The following example uses two Variable components: vCustomerTotal and
vCustomerSummary. The variable vCustomerTotal has its Timing defined to
Reset on GroupEnd.
There are two options for accumulating the summary total.
1. Use the vCustomerTotal OnCalc event to accumulate the detail and the
summary.
example:
procedure vCustomerTotalOnCalc(Sender: TObject; var Value: Variant);
begin
if (plCustomer['Amountpaid'] > 100.00) then
begin
{sum detail}
Value := Value + plCustomer['Amountpaid'];
{accumulate summary}
vCustomerSummary.Value := vCustomerSummary.Value +
plCustomer['Amountpaid'];
end;
end;
2. Set the timing of the Summary OnCalc to "GroupBeforeFooter" and
accumulate the detail variable results. Note that here we use
GroupBeforeFooter because the detail variable has its Reset defined as
"GroupEnd" - implying that if we try to use GroupEnd for our summary
calculation the accumulated results will be 0.
example:
procedure vCustomerTotalOnCalc(Sender: TObject; var Value: Variant);
begin
{sum detail}
if plCustomer['Amountpaid'] > 100.00 then
Value := Value + plCustomer['Amountpaid'];
end;
procedure vCustomerSummaryOnCalc(Sender: TObject; var Value: Variant);
begin
{accumulate summary}
Value := Value + vCustomerTotal.Value;
end;
--
Nard Moseley
Digital Metaphors Corporation
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Why does the "GroupFooterBand AfterGenerate" fire twice ?
Is there no way to calculate a total that only fires once for each group ?
Thanks
Petter
Try placing a TppVariable in the Group footer. Position mouse button over
the TppVariable, press the right mouse button and select the Timing.... menu
option. Select CalculateOn BeforeGroupFooter and use the drop down list box
just below to specify the Group.
In general using the Band events does not work very well because they often
fire multiple times - as you have witnessed. You could try using
Band.AfterPrint and see whether that works any better.
--
Nard Moseley
Digital Metaphors Corporation
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
The OnCalc event on the Vairiable field in the footer only fires once.....
Petter
PS. Althoug I find the ReportBuilder a big improvement on the earlier
QuickReport shipped with Delphi, I end to get fairly confused with all the
events, and the wich one to use, and in wich order. The lesson I have
learned this time is, that I will have to TRY to make things as simple as
possible...... :-)
It seems I was too quick, the problem seems to have moved...
I now have a situation where the Masterreport and Subreport are out of sync.
The SubReport consquently is one record behind, any suggestions ?
Thanks
Petter
I see that you created and new thread and Nico posted an example - perhaps
that will help....
--
Nard Moseley
Digital Metaphors Corporation
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Run the RBuilder\Demos\Reports\Demo.dpr and select the Events section. This
section contains Event Tracker demos that visually show the events as they
fire. You can use the same technique to visually track the events in your
own reports.
--
Nard Moseley
Digital Metaphors Corporation
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com