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

How to calculate a total of a total

edited May 2002 in General
On each detail line I have a calculation (using a TppVariable) to calculate
ColA - ColB - ColC. Call this variable Var1.

In the summary band for the report I want to calculate Sum (ColA) - Sum
(ColB) - Sum (ColC), equals Sum (Var1).

I already am using TppDBCalcs for Sum (ColA), Sum (ColB) and Sum (ColC). I
can't figure out how to get Sum (Var1), though. Any help is much
appreciated.

Comments

  • edited May 2002
    In the OnCalc of Var1, add the value to total as well:

    Value := {your formula here};

    TotalVar.Value := Value;

    end;

    With this approach, TotalVar will not have any event handlers assigned...

    --
    Cheers,

    Tom Ollar
    Digital Metaphors Corporation
  • edited May 2002
    My TotalVar.Value would be

    TotalVar.Value := TotalVar.Value + Value;

    with an initialization of TotalVar.value := 0 before the report starts.

    This would work if each row in my dataset were traversed only once. It
    seems, though, that when I page up and down through the report, the
    var1.onCalc events fires multiple times for the same row, and my
    totalVar.value isn't calculated correctly.

    Maybe I need to change a property? Is there another suggestion?

  • edited May 2002
    Hi Keith,

    The 'OnCalc' should be fired only once per row. Do you manipulating the data
    during traversion? Try setting 'cache pages' to true.

    regards,
    Chris Ueberall;

  • edited May 2002
    I used a variation on Tom's idea to solve my problem. Instead of using the
    Var1 onCalc event (which occurs for each for in the report) I'm using the
    calc event of my summary DBCalc objects. Thanks for the help.

This discussion has been closed.