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

Using of ppDBCalc Lookahead Value

edited November 2001 in General
Hi

I want to create a Report which should look like the following example

Group Header
Val Sum per cent
3 12 40%
5 12 42%
4 12 30%
Sum 12

....more groups ...

therefore i put the following in the detail band
ppDBText1 ppDBCalc1 ppLabel1

both connected to the same numerical field
ppDBCalc1.LookAhead=true
ppDBCalc1.dbCalcType=dcSum

I thought in ppLabel1.onPrint I could do something like
if ppReport.Secondpass then
ppLabel1.caption:= DataSet.fieldbyname('Val').asFloat/ppDBCalc1.value;

but it don?t work that way

(ppReport.PassSetting=psTwoPass of course)

I use RB6.03 Std

can somebody help me?

best regards,
Oliver

Comments

  • edited November 2001
    The look ahead fails when you want to use it in a calculation like this.
    For the percentages, you will need to code a list of summary values for the
    group totals. Then in the second pass, pull the totals for the group out of
    the list in the calculation instead of using the LookAhead values.

    The LookAhead values are implemented such that the draw commands are altered
    when the final calculation is performed for the total. This means that all
    the calculation event to generate the page, have already been fired, so the
    LookAhead value is going to be assign too late.


    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited November 2001
    I have a report will almost the same logic. This is what i've done:
    The report was set to TwoPass. On the first pass i calculate the SUM column, in
    the second pass i calculate the Percentage column.
    I stored the SUM value into a private delphi variable and had careful about only
    increment it on the first pass of the report.
    It works fine for me.
    bye

This discussion has been closed.