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

The sum of a Variable

edited December 2006 in RAP
I entered variable2 in a report to find the value of the qty * price. Works
fine. Now I want to find the sum of all the values in variable2. I entered
a variable in the footer and tried to enter code like Value :=Sum.Variable2;
no good.

What is the correct syntax for using Sum in this situation?

Comments

  • edited December 2006
    I found something that worked- Value:= Value + Variable2.Value;

    But now I have a new problem. The group footer has the variable that's
    adding up the value of Variable2 but as the group changes the tally
    continues. So although each group breaks on a new page the total is a
    running total of all. How do I stop this?

    Thx,
    Chris

  • edited December 2006

    Position the mouse of the Variable in the GroupFooter. Press the right mouse
    button and select the Timing... menu option. Use the Timing dialog to
    configure the variable to reset on group end.


    Some tips on performing Calculations...
    -------------

    Calculations in ReportBuilder are performed primarily using
    the TppVariable component.

    a. Set the Variable.DataType

    b. Code the calculations using the Variable.OnCalc event.

    c. Use the Timing dialog to control the timing of the OnCalc event.
    To access the Timing dialog, right click over the Variable
    component and select the Timing... option from the speed menu.

    d. Set the LookAhead property to True, when you need to display
    summary calculations in the title, header, group header, etc.

    e. To perform calculations based on the results of other
    calculations use the Calc Order dialog of the band. To access
    the Calc Order dialog, right click over the Band component
    and select the Calc Order... option from the speed menu.


    By using TppVariable components ReportBuilder will take care of caching
    intermediate results of accumlated calcs that cross pages.

    There are a number of calculation examples in the main demos.dpr
    project.

    ---

    Additional Notes:

    1. Do NOT use Band.BeforePrint or Band.AfterPrint. These events fire
    multiple times and therefore should not be used for calculations.

    2. Do NOT store results in variables that exist outside of the reports.
    For example - form level variables.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.