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

Calculate a total for all the subreport rows and place in the summary of the main report.

edited November 2002 in Subreports
Hi, all

I have a master detail report with a sub report where there are the detail
rows.

How i can calculate a total for all the subreport rows an place at the end
of my main report in the summary band ?

Thanks in advance.

Massimo.

Comments

  • edited November 2002

    Try downloading the following example

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

    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2002
    Thank you for the answer but with your example I don't solve my problem.

    Refer to your exemple i must sum the field Amountpaid for all the rows of
    all the orders and put this total in the main report.

    Do you have an example that explain how do this ?

    Massimo
  • edited November 2002
    It is going to be the same approach as the demo. Examine the demo. It shows
    a technique that lets you perform calculations in a subreport and show them
    in the main report. Does this not make sense? Yes, it is a little
    confusing at first. Essentially, the reason it has to be done this way, is
    that the variables in the subreport don't carry over from one subreport to
    the next, and also that the main report can't see into the subreports, as
    the scope of the components is limited to the subreport they are in. This
    is why we create a global pointer to the variable which is located in the
    main report, so that the different subreport variables' OnCalc event
    handlers can access the main report via a pointer to it instead of
    referencing the variable in the main report by name.

    Take the variable and use the OnCalc to create a running grand total of a
    field value from the data pipeline instead of a counter. You can place the
    variable in the summary band if you don't want it in the detail band of the
    subreport. The OnCalc will fire for every traversal of the detail subreport
    pipeline as it would if it were in the detail band.

    Value := Value + plOrders['AmountPaid'];


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited November 2002
    Now all works fine.

    Thanks a lot.

    Massimo.
This discussion has been closed.