Totals on Report Inaccurate
I'm getting inaccurate totals on my report and I've tried two different ways
to do it. Delphi 7 and RB Version 10.07.
Here's the scenario: I have a main report (we'll call this project) that is
bound to a pipeline. Under that report's detail band I have two child
subreports connected to two different pipelines. I need to total the prices
of the detail items printed from subreport1 and subreport2 and have it print
in the summary band of my Project report.
Subreport 1 prints these values:
705
988
1128
2484
1500
Subreport 2 prints values:
134
144
270
561
0
135
270
288
0
0
0
60
69
144
189
39
78
78
This should total 9264. Thus, on my summary band I put a DBCalc to sum the
values of my pipeline for subreport1 for field EXTENDED_PRICE; however, it
just pulls the first value 705. I thought I could later calculate the sum
from DBCalc1 and DBCalc2 where they would total the values from subreport1
and 2 but it doesn't look like it will even pull the approprate value.
To get around this issue I created a variable component and on both
subreports' detail bands I total the values subsequently adding the current
record value to the variable. This almost works. The problem is that I'm
getting 129 extra. I did a show message on the detail bands' print events
and the values 0,0,0,60,69 from subreport2 are getting printed a third time
which is why I'm getting an additional 129.
This only seems to be a problem when printing more than one page. Please
advise.
Thank you.
to do it. Delphi 7 and RB Version 10.07.
Here's the scenario: I have a main report (we'll call this project) that is
bound to a pipeline. Under that report's detail band I have two child
subreports connected to two different pipelines. I need to total the prices
of the detail items printed from subreport1 and subreport2 and have it print
in the summary band of my Project report.
Subreport 1 prints these values:
705
988
1128
2484
1500
Subreport 2 prints values:
134
144
270
561
0
135
270
288
0
0
0
60
69
144
189
39
78
78
This should total 9264. Thus, on my summary band I put a DBCalc to sum the
values of my pipeline for subreport1 for field EXTENDED_PRICE; however, it
just pulls the first value 705. I thought I could later calculate the sum
from DBCalc1 and DBCalc2 where they would total the values from subreport1
and 2 but it doesn't look like it will even pull the approprate value.
To get around this issue I created a variable component and on both
subreports' detail bands I total the values subsequently adding the current
record value to the variable. This almost works. The problem is that I'm
getting 129 extra. I did a show message on the detail bands' print events
and the values 0,0,0,60,69 from subreport2 are getting printed a third time
which is why I'm getting an additional 129.
This only seems to be a problem when printing more than one page. Please
advise.
Thank you.
This discussion has been closed.
Comments
Place a variable inside each of the subreports' detail band and use their
OnCalc event to update the variable in the main report. Be sure the
variables placed in the subreports have their Visible property set to false
and their datatype set to a numerical type (i.e. Integer).
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Calculations/Overview
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
additional 705 to the total which should be 9264. If you look at the list of
numbers, it's adding the first number of subreport1 again which is 705 to
give me a grand total of 9964.
In Subreport1's detail band I added a tppvariable with the name:
ppvarMaterialExtendedPrice.
In Subreport2's detail band I added a tppvariable with the name:
These are those variables' onCalc events:
procedure TfrmMatEst.ppvarMaterialExtendedPriceCalc(Sender: TObject;
var Value: Variant);
begin
vTotalExtension.AsCurrency := vTotalExtension.AsCurrency +
dsEstMatEXTENDED_DISCOUNT_PRICE.AsCurrency;
end;
procedure TfrmMatEst.ppvarMaterialAttrExtendedCalc(Sender: TObject;
var Value: Variant);
begin
vTotalExtension.AsCurrency := vTotalExtension.AsCurrency +
dsMatEstimateAttrEXTENDED_DISCOUNT_PRICE.AsCurrency;
end;
In these events I tried adding an if statement to determine if this is the
report's first/second pass but that was even worse.I've also tried changing
the timing of these variables to dbtraversel from traversal but then it adds
an additional 1827. In all scenarios I've had it reset at ReportEnd.
Thank you.
1. Try upgrading to the latest version of RB 10. (10.09). Contact
info@digital-metaphors.com with your serial number and purchasing email
address for upgrade instructions.
2. Take a look at the examples on this article.
http://www.digital-metaphors.com/rbWiki/Delphi_Code/Calculations/How_To...Display_Subreport_Totals_in_the_Main_Report
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com