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

Use calculation from subreport in other calculation of main report

edited October 2006 in Subreports
Hi,

In a purchase order I print order lines (products) in the detail band. Each
order line can contain sub order lines (optional product parts). These are
printed in a child sub report as part of the detail band. Each product can
have a product property 'weight'. By calling a RAP function I can calculate
the weight for that product. What I need is to print the weight for order
lines and sub order lines where the weight of a order line is the weight of
the product plus the weight of it's sub products multiplied by the amount.

Example:

Product 1 2pc 42,2 kg
Subproduct 1.1 1pc 0,8 kg
Subproduct 1.2 1pc 0,7 kg
Subproduct 1.3 8pc 13,6 kg
Product 2 1pc 6,0 kg
Product 3 3pc 4,5 kg
Subproduct 3.1 1pc 0,1 kg
Subproduct 3.2 2pc 0,2 kg
Product 4 8pc 4,0 kg
Subproduct 4.1 3pc 0,0 kg

Sum 56,7 kg

I use a global gPartWeight referencing a ppVariable, varPartWeight in the
main report detail band. gPartWeight is set in the summary of the sub report
by the OnCalc of another variable. When I print this varPartWeight it
displays the correct weight. The result of varPartWeight however should be
added to the weight of the main product in the detail band. It seems however
that at the moment I want to calculate the total of product + sub product,
the sub product weight is not calculated yet (it holds the value of the
previous sub products).

How can I use the result of a calculation in a sub report in another
calculation in the main report?


Using D7, RB10.04 Ent

Regards,
Jeroen R?ttink

Comments

  • edited October 2006
    Hi Jeroen,


    When are you calculating the product + sub product? This sounds like a
    timing issue in that you are making this calculation too early and the total
    weight is being calculated before the sub product is. My first suggestion
    would be to create this report using Delphi code so you can debug your event
    code and find out when each OnCalc is firing. Have you tried setting the
    variable in the main report to LookAhead?

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2006
    Nico,

    I debugged the report using Delphi and got the timing problem. Everything
    works ok now.
    LookAhead with the correct reset properties where indeed the key to this
    problem.

    Regards,
    Jeroen.

This discussion has been closed.