Grand Totals from conditional Group Totals
After all this time of using RBldr I should know
how to do this properly....
I have a table with records of the form:
A XYZ 22.00
B QRT 33.00
A CFF 35.00
A CFF 56.00
B JKL 44.66
I am printing out group totals (based upon the 2nd column)
but only if the field in column 1 equals "A"
I do not print out a detail line.
Output for the above example would be
Total for XYZ = 22.00
Total for CFF = 91.00
Grand Total = 113.00
The B records are to be ignored.
I have no problem controlling the print out of the group
totals by using .visible := false/true;
My problem is accumulating the grand total. Where
do I put the equivalent of
if Fld1 = 'A' then
GrandTotal := GrandTotal + Fld3.value; ?
I find that single page reports work fine if the
calculation is in the BeforeGroupPrint but multiple page
reports get the wrong total because the before print
fires more than once.
I have a complex work-around but figured there's
got to be a simple solution without using RAP or
creating a table with only "A" records.
Jon
--
Jon Lloyd Duerdoth
Welsh Dragon Computing
http://www.welshdragoncomputing.ca
Visit All Saints' Kingsway Anglican Church
http://www.allsaintskingsway.ca
how to do this properly....
I have a table with records of the form:
A XYZ 22.00
B QRT 33.00
A CFF 35.00
A CFF 56.00
B JKL 44.66
I am printing out group totals (based upon the 2nd column)
but only if the field in column 1 equals "A"
I do not print out a detail line.
Output for the above example would be
Total for XYZ = 22.00
Total for CFF = 91.00
Grand Total = 113.00
The B records are to be ignored.
I have no problem controlling the print out of the group
totals by using .visible := false/true;
My problem is accumulating the grand total. Where
do I put the equivalent of
if Fld1 = 'A' then
GrandTotal := GrandTotal + Fld3.value; ?
I find that single page reports work fine if the
calculation is in the BeforeGroupPrint but multiple page
reports get the wrong total because the before print
fires more than once.
I have a complex work-around but figured there's
got to be a simple solution without using RAP or
creating a table with only "A" records.
Jon
--
Jon Lloyd Duerdoth
Welsh Dragon Computing
http://www.welshdragoncomputing.ca
Visit All Saints' Kingsway Anglican Church
http://www.allsaintskingsway.ca
This discussion has been closed.
Comments
Really the only way around the fact that the GroupBeforePrint event fires
more than once is to either keep track of which group you are currently in
when the event fires or to use the OnCalc event to another TppVariable set
to calculate when that group breaks.
As you probably know, the OnCalc event of the TppVariable will only fire
once per calculation interval so if you are able to get this working, it
would probably prove to be the best solution. Otherwise, you could keep a
global group break value that you check against the current break value each
time you enter the GroupBeforePrint event, then run the calculation
accordingly.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
fires if the band actually prints. The only issue we have with doing it this
way is that if the Group is split across multiple pages then the event fires
a second time. We solved this problem by ensuring the Keep Together property
of the band was set to True.
I'm certain that the above works and I really hope that it does because we
use this technique all over the place.
Scott
I guess my solution is OK (since it works :-) )
I'm going to try Scott's solution as well
Jon
working on your idea but still get different
totals when I spread the report out (to
force different paging). I'll check further.
Jon
Everything works as expected once I followed the suggestions.
Thanks,
Jon