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

At detaillevel groupfooter variables are changed on page x, but not on page x+1

edited April 2006 in General
Hi,

I noticed some strange behavior. If I update group footer variables at a
detail level (for instance in the Procedure DetailBeforePrint) to make a
(sub)totalization, I get the wrong values when there's a end-of-page. It
looks like on page X the procedure DetailBeforePrint executes because the
values on GroupFooter1 are changed, but on Page X+1 the values on
GroupFooter2 have not changed, like DetailBeforePrint never executed. First
or secondpass don't make a difference. I have added a MS-Word document to
make things visible.

I have tested whether using global variables show the same behavior. No, but
then skipping pages in the preview doesn't work that well.

Best regards,

Geert-Jan Fluitman
Meurs Software Nederland
(the netherlands)

Comments

  • edited April 2006
    Hi,

    ----------------------------------------------------------------------
    TECH TIP: Performing Calculations
    ----------------------------------------------------------------------

    Calculations can be done either on the data access side
    or within ReportBuilder.

    When designing reports there are always decisions to be made as to
    how much processing to do on the data side versus the report side.
    Usually doing more on one side can greatly simplify the other. So it is
    often a personal choice based on the power and flexibility of the data
    and report tools being used.


    DataAccess
    ----------

    a. Use SQL - using SQL you can perform many common calculations:

    example: Select FirstName + ' ' + LastName As FullName,
    Quantity * Price AS Cost,


    b. Delphi TDataSets enable you to create a calculated TField object
    and use the DataSet.OnCalcFields event

    c. Perform any amount of data processing, summarizing, massaging
    etc. to build a result set (query or temp table) to feed to the report.


    ReportBuilder
    -------------

    Calculations in ReportBuilder are performed primarily using
    the TppVariable component.

    a. Set the Variable.DataType

    b. Code the calculations using the Variable.OnCalc event.

    c. Use the Timing dialog to control the timing of the OnCalc event.
    To access the Timing dialog, right click over the Variable
    component and select the Timing... option from the speed menu.

    d. Set the LookAhead property to True, when you need to display
    summary calculations in the title, header, group header, etc.

    e. To perform calculations based on the results of other
    calculations use the Calc Order dialog of the band. To access
    the Calc Order dialog, right click over the Band component
    and select the Calc Order... option from the speed menu.


    By using TppVariable components ReportBuilder will take care of caching
    intermediate results of accumlated calcs that cross pages.

    There are a number of calculation examples in the main demos.dpr
    project.

    ---

    Additional Notes:

    1. Do NOT use Band.BeforePrint or Band.AfterPrint. These events fire
    multiple times and therefore should not be used for calculations.

    2. Do NOT store results in variables that exist outside of the reports.
    For example - form level variables.


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2006
    But can you also explain why a calculation done on pages X has been undone
    at page X+1.

    I've spend some thought on this subject and this is my hypothesis. It look
    likes reportbuilder first calculates starting values for all
    footer-variables per page and when this page needs to be shown it
    recalculates the page. So when the starting values are not calculated
    properly, calculations (in my case summerizations) are not done on page X+1,
    but are on page X. This way I get totally wrong totalizations, or at least
    unreliable ! Global variables don't have this problem, but give different
    problems in the preview when skipping pages.

    Am I right ?
    How can I work around this problem ?



  • edited April 2006
    Hi,

    You need to be sure you are making all calculations inside the OnCalc event
    of a TppVariable in order to ensure that the calculation is made properly.
    I am unsure what you mean by "global variables". Is this in RAP?

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2006
    I am enclosing a word document to show you what i mean by global values.
    Maybe a bad translation. I've tried the OnCalc event and i'm afraid that
    doesn't work either.

  • edited April 2006
    Hi,

    For future reference, please send all attachments to
    support@digital-metaphors.com.

    I would first recommend getting your application working in Delphi before
    moving to RAP. This gives you a chance to debug your event code to find out
    exactly how the RB events behave. If you are using TppVariable objects and
    their OnCalc events, the calculations made inside this event will only be
    executed once. If you are executing any event code that alters the report
    elsewhere, the event could fire more than once and give you wrong results.
    If you are able to recreate this issue with a minimal example I could run on
    my machine, please send it in .zip format to support@digital-metaphors.com
    and I'll take a look at it for you.

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2006
    It is going to be verry difficult for you to find out the problem without
    the testdata I'm using. Do you have an Oracle database (version 8.1.7 or
    higher), so I could send you the testdata also ?

  • edited April 2006
    Hi,

    Unfortunately I do not currently have Oracle installed on my machine. Is is
    possible to recreate a similar situation using the DBDEMOS database included
    with Delphi? Have you tried moving all your calculation code to Delphi so
    you can trace it and see what exactly is happening as the report generates?

    --
    Regards,

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

    Best Regards,

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