Problems with calculate Grand Totals in Report
Hi !
I have a problem with calculate totals in report.
I attached small examples with this problem.
What did I make incorrect ?
Thanks.
Roman Koval.
I have a problem with calculate totals in report.
I attached small examples with this problem.
What did I make incorrect ?
Thanks.
Roman Koval.
This discussion has been closed.
Comments
Do not use the generation events of the bands as they may fire more than
once when the band tries to fit on a page but can't so it has to regenerate
on the next page.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Please look at examples in attachment.
There is grand total calculated in OnCalc event handler (in RAP code) and
control grand total calculated in SummaryBeforeGenerate
( in Delphi code).
Those totals are defferent.
Thanks.
than TppVariable.OnCalc. Only use TppVariables and TppDBCalcs for
calculations. Do not store calculation values inside of Delphi variables.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I calculated totals in BeforeGenerateSummary like this:
procedure TForm1.ppSummaryBand1BeforeGenerate(Sender: TObject);
begin
vCSumOfAmount.AsDouble := 0;
vCSumOfTotal.AsDouble := 0;
tblCustomers.First;
while not tblCustomers.Eof do
begin
while not tblOrders.Eof do
begin
vCSumOfAmount.AsDouble :=
tblOrders.FieldByName('AmountPaid').AsFloat + Amount.AsDouble;
vCSumOfTotal.AsDouble := tblOrders.FieldByName('ItemsTotal').AsFloat
+ vCSumOfTotal.AsDouble;
tblOrders.Next;
end;
tblCustomers.Next;
end;
end;
And this result is correct.
But, if I use TppVariables OnCalc event handlers - result is incorrect.
Maybe you don't understand my problem.
Can you see samples in attachment at last.
Thanks.
Roman Koval.
a subreport connected to a detail dataset. Here is an example which shows
how to use variables inside the subreport to calculate the correct number of
times (once for each detail record) and then update variable values in the
main report's summary band as it calculates:
http://www.digital-metaphors.com/tips/SubreportTotalsInMainSummary.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Thanks for example.
But if I changed property ppSubReport1.KeepTogether := True report was
generating incorrect.
Try it.
Roman K.
project to cache the calculations as an added feature.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com