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

Sum problem (Newbie)

edited September 2002 in General
Hi !

I have just started using Report Builder, and have run into a, I hope,
simple problem.

My report consists of a Main Report with a SubReport with PrintBehavior set
to pbChild.
In my Main report I have a ppDBCalc field that produces a sum, In the
SubReport I also have a ppDBCalc field that produces a sum.

I have tried to make a sum out of these two using a variable field, but at
the time the GetText of the variable field fires, the value of the DBCalc
fields have not been completely calculated. In fact it seem that the
position of the calc field is in the first record of the dataset.

Can anyone help me on how to calculate a field from a subreport with a field
on the main report ?

Petter

Comments

  • edited September 2002
    Hi again !

    I solved the problem by reading the value of the ppDBCalc.Value on the
    AfterGenerate event of the Band.
    And then I calculated the total.

    Petter
  • edited September 2002
    You can also use TppVariables and in the OnCalc evnet handler of the
    variable in the subreport, update the value of a variable in the main
    report. This way you'll only have one event handler that updates both the
    variable in the subreport and the variable in the main report.

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Hi Jim !

    Why use the event handler of variable in the subreport ?
    Is it the Subreport that is executed first ?

    Petter
  • edited September 2002
    You can use one event handler because this way the eent gets fired once for
    every detail record. You can then use this to update the variable in the
    main report. The variables only calculate based on the record change of he
    report that they are in. The variable in the main report will onyl fire its
    OnCalc as the master repot's data pipeline is traversed. The subreport's
    veriable will fire for every detail record in the report. If you want a
    running total or calculation in the main report based on the subreport, then
    you can use this approach to do so.

    Here is an example of using variables to perform calculations over groups of
    data:

    http://www.digital-metaphors.com/tips/PercentageOfGroupTotal.zip

    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.