Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Grand Totals from conditional Group Totals

edited October 2004 in General
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

Comments

  • edited October 2004
    Hi Jon,

    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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2004
    We use the BeforeGenerate event of the band as it only fires once and only
    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

  • edited October 2004
    Thanks Scott & Nico,
    I guess my solution is OK (since it works :-) )

    I'm going to try Scott's solution as well

    Jon


  • edited October 2004
    Scott,
    working on your idea but still get different
    totals when I spread the report out (to
    force different paging). I'll check further.

    Jon


  • edited November 2004
    The TechTips on calculations were the answer.
    Everything works as expected once I followed the suggestions.

    Thanks,
    Jon


This discussion has been closed.