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

Page Subtotal

edited February 2004 in General
I want to calculate a page subtotal of a column, At first I try to use a
variable (e.g. subtotal) and sum the variable at the aftergenerate event of
detail band. (subtotal := subtotal + field.value). By I find that if there
are more than one page, then sometimes the aftergenerate will execute one
more than expected (e.g. if there are 23 rows in the detail band of the
first page, the detailband.aftergenerate will execute 24 times), so the page
subtotal calculated is wrong.
So, Is there any suggestion to calculate page subtotal of a column in a
detail band and display the page subtotal in page footer band?

Comments

  • edited February 2004
    Hello,

    If you are calculating a sum in the page footer and using a dynamic height
    detail band, you are probably seeing a limitation of ReportBuilder. The
    only way to work around this issue is to make the calculation for the sum in
    the detailband.afterprint event. Note that this event may fire more than
    once per record so you will need to add some logic to account for that
    possibility.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2004
    then what is the logic, how can I know when it will calculate more than once
    for a record and when it will not? Is there no methods to calculate page
    totals?
  • edited February 2004
    Hi,

    Sorry, I mis-read your first post. Before trying to solve the issue with
    the DetailBand.AfterGenerate, try making all calculations related to your
    total variable in the OnCalc event of another variable inside the detail
    band. Simply place an invisible TppVariable inside the detail band and in
    its OnCalc event update the variable in the footer band. If you still have
    an issue after doing this, you can try making the calculation in the
    DetailBand.AfterPrint with logic that checks the current record every time
    the event if fired. This way if the record is the same twice, the code
    inside the event will not get fired.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.