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

TppVariable Page Calculation Problem

edited January 2002 in General
Hello,

Using:
-RBStd 5.56
-Delphi 5

I'm using a TppVariable to calculate page level sub-totals. Single page
groups work fine however when a group spans more than one page the first
page total includes the first group record of the second page and the second
page total excludes the first group record of the second page, making the
first page total too high and the second page total too low. An example
would be;

Page 1 with values 10,30,20 calculates as 70 should be 60
Page 2 with values 10,50,40,10 calculates as 100 should be 110

I appear to be catching the reset in the wrong place (?), -

ppVar in Footer Band (same result when put in Detail),
- CalcType: veTraversal
- ResetType: vePageEnd (same result when vePageStart)
- LookAhead: False (same result when True)

On Calc Event:
ppVar.AsDouble := ppVar.AsDouble +
ppDBPipelineInvoices.GetFieldAsDouble('Invoices.Amt');

Any help would be appreciated.

Thanks,
Stephen

Comments

  • edited January 2002



    I remember that this was a problem in the older versions. I tried to
    reproduce the problem in 6.03, but the OnCalc appears to be working
    correctly as the group breaks over multiple pages. Try upgrading to 6.03 to
    see if the problem goes away for you. Contact info@digital-metaphors.com
    with your full registration information.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited January 2002
    Hi Jim,
    Thanks for the reply. I installed 6.03 and problem still exists, I'll keep
    at it but in the meantime if you have any other ideas I'd appreciate it.
    Thanks,
    Stephen


  • edited March 2002
    Hi all..

    sure that this problem ocurrs in my application too. How to solve this
    problem.. please, reportbuilder support, answer this question to resolve
    this problem...

    Thanks...

    "Stephen Hall" escribi? en el mensaje
  • edited March 2002
    Sorry, I missed this post. When the page generates, the OnCalcs fire.
    However, when the detail band doesn't fit, the OnCalc has already fired for
    the next record. Since we don't want the OnCalc to fire again, it isn't and
    the value is stored for the next page, when the detail gets a chance to
    print. This is just an artifact of how the engine is built to handle firing
    the OnCalcs one time. To workaround this, you can place a variable in the
    footer band. I have a variable in the detail band whihc is summing the
    values from the datapipeline. I then use a label in the footer band to show
    the total from the variable in the detail band. When I do this, I get the
    behavior you describe. So, I then use the DetailBand.After print event to
    check to see if the band didn't fit to set the footer variable to the value
    to the variable which is summing the value. I can send you an example if it
    would better illustrate the workaround. Basically, you'll want to only
    cache the sum values which printed inside of the detail bands that fit on
    the current page.

    procedure DetailAfterPrint(aSender: TObject);
    begin
    if not(Detail.OutOfSpace) then
    vblFooterTotal.Value := vblDetailTotal.Value;
    end;

    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.