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

Lookahead value problem

edited January 2002 in General
Hi,

I have a problem while using lookahead value!
Following is my report layout:

Group Header Band:
- calGroupTotal: TppDBCalc -> A hidden control to sum Qty, with
Lookahead=True, reset on ppGroup1. Result a Group Total.

Detail Band:
- dbQty : TppDBText -> Show quantity
- varQtyRatio: TppVariable -> Show Ratio of quantity to Qty Group Total.

Group Footer :
- calQty: TppDBCalc -> Show quantity group total
.
Page Footer:
- calTotalQty: TppDBCalc -> Show quantity grand total

The problem control is varQtyRatio! I try to use calGroupTotal.Value to
calcuate the value in varQtyRatio.OnCalc event but failed. The
calGroupTotal.Value always restart calcuation of group total so that the
calculation failed. How can I make a correct calcuation in varQtyRatio?

Thanks for any advance.

Stephens

Comments

  • edited January 2002
    If you are using a LookAhead value from a DBCalc in a variable's
    calculation, then be aware that you will get inconsistent results.

    The reason for this behavior is that when the DBCalc prints, and if the rest
    of the detail bands on the page have not generated, then the datapipeline
    may not been traversed for all of the values that need to be included in the
    DBCalc's value. The current report engine handles calculating LookAhead
    values by letting the DBCalc's OnCalc fire on the record traversal, as the
    detail bands generate on the page. Once the page has completed, the DBCalc's
    draw command on the page is updated with the latest LookAhead value.

    One solution would be to create a calculated fields on your dataset.

    Another solution is to not use DBCalcs at all, and instead build the totals
    in the first pass and use them in calculations during the second pass. Set
    the Report.PasSetting to psTwoPass. Then as the report generates in the
    first apss, store the group totals in a TList. Now, the Report.FirstPass and
    SecondPass boolean properties can be used to determine if the report is in
    the second pass (which will happen when you preview or print). Now you can
    extract the total for hte group from the TList and us it in the variable's
    calculation. Use a variable in the group header band if you want to display
    the group total there.


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.