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

Wrong sub-report totals on master footer

edited September 2002 in Subreports
Hi,

I have this problem when I totalize a sub-report on the footer page on
master band;
If I print several page, the total printed on the first page contain even
the first detail printed on the second page; The total on summary, at the
end of report, is correct;
I use a TppVariable into subreport that sum value on OnCalc Event;
I use a TppVariable into Master Footer that take the value from the
subreport variable on OnCalc Event; this because I cannot use a DBCalc sum
across subreports into Master band automatically (...or yes?);

Ex.
main aaaaaaa sub 1
sub 2
sub 3
main bbbbbb sub 12
sub 2
sub 4

footer main page 27 (contain also 3 in next page);

main ccccc sub 3

What is the correct way from cal running totals of subreports into main
footer ?

Thank you in advance!
(Sorry for the poor english)

Stefano Monterisi

Comments

  • edited September 2002
    DBCalcs won't work across subreports in a main report. What you can do is
    use TppVariables to perform the calculation. Here is a demo which
    demonstrates this technique to show the detail totals in a main report
    summary band.

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

    Note: This tip works as long as the detail of the subreport is not
    stretching. I'll have to modify the tip to work with that configuration.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Hi Jim,
    thank you for fast response;
    (sorry for the direct email, I have clicked on Reply...)


    I already use Tppvariables for this and those works well;

    The totals into summary are always correct;

    The wrong result is present I print those variables on the footer page of
    main report (as running totals) ;
    The footer present all the right totals plus the first next detail present
    on subreport, that is printed on the next page;
    The variables are incremented with the new detail (that is on next page)
    BEFORE footer printing;

    If I don't use OnCalc variables in subreport, but if I calculate totals on
    AfterPrint event into subreport, than the main footer is correct.

    But, I have read that AfterPrint can fire several times, so the totals might
    be wrong in some cases; Or not ? :-)

    Thank you in advance.

    Stefano Monterisi

  • edited September 2002
    What happens is that the calcs fire when the band tries to generate. If it
    can't fit, then it moves to the next page, firing the calc again. When the
    variable is in the band.the report engine takes care of caching the value
    and restoring it across a page break. But when you place the variable in the
    footer, it has one extra value in it for the first record on the next page.
    The band after print event can fire multiple times.

    What you can do is use TppVariables in the subreport's detail band in order
    to update the values in the TppVariables in the main report footer band as
    shown in the previously posted demo link.

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited October 2002
    Hi Jim,

    you are correct;

    but the summary totals are always correct (like example);
    The problem is only on the footer of main report;

    I have use this method (like you suggest me);

    I have a ppVariable1 on main report (detail band) and a ppVariable2 on
    subreport (detail band);
    I have also a ppVariable3 on footer of main report;

    I use this on Oncalc event of ppVariable2:

    1) ppVariable3.value := ppVariable1.value; (old value)
    2) ppVariable1 := ppVariable1 + mydbpipeline['myfield']; (newest value);


    Is this that you intend ?


    But, one of my report have the subreport detail band that have this format:

    100,00 50,00
    [not sale]
    200,00 70,00
    120,00 60,00
    [not sale]
    130,00 80,00


    In other word I have a dynamic band that can print other information;

    I this band is across the page break, in the footer I don't find the latest
    value before the footer because the band is not printed completly;

    So I have :
    ...
    100,00 50,00
    [not sale]
    200,00 70,00
    120,00 60,00
    ---300,00-120,00--------(footer wrong result, the correct are 420,00 and
    180,00)
    [not sale]
    130,00 80,00

    etc...

    Ok ?

    I hope that you can understand my poor english :-)


    Stefano Monterisi
  • edited October 2002
    Hi Jim,

    It work.

    I use a ppVariable on main detail report and another ppVariable on detail of
    subreport;
    The main variable is incremented on OnCalc of the second one;

    The problem is to find the event (that fire only one time) for setting the
    footer variable... I have used OnGetText of another field that is printed in
    detail band of the subreport and it works;

    It is correct this way ?

    Thank you for help

    Stefano Monterisi
  • edited October 2002
    The OnGetText will fire every time that component's Text property is
    referenced, either by your code or the internal report engine. Instead of
    the OnGetText event of another control, you could place another variable in
    the detail band of the subreport and use its OnCalc event. You can set the
    visibility of the variable to false and it will still calculate, but will
    not show up in the output.


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.