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

instance of TppVariable always 0

edited May 2005 in General
I have a variable named ftr_Total of type TppVariable in my report. I have
set the timing to be ReportEnd (reset) and ReportEnd (calc). This variable
lives in the summary band of my report. The DisplayFormat property is
empty. This is a two-pass report. I have hardcoded the OnCalc event:

procedure TMyDM.ftr_TotalCalc(Sender: TObject; var Value: Variant);
begin
ftr_Total.Value:= 1234; //breakpoint set here
end;

I have also set a breakpoint on the Reset event:

procedure TMyDM.ftr_TotalReset(Sender: TObject; var Value: Variant);
begin
sleep(0); //breakpoint set here too
end;

When I print the report, these breakpoints are reached in this order:
RESET
CALC

To my surprise, the displayed value is ALWAYS zero (0). What is going on
here?

Comments

  • edited May 2005
    Hi Tyler,

    The setting for ReportEnd was mainly designed to be used as a reset flag.
    What exactly are you trying to accomplish in your report? (i.e. what value
    would you ultimately like displayed in your summary band?)

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2005
    Regardless, why would the value be displayed as 0 after 1234 has been
    assigned and the reset event never fires again?

    Originally, I was trying to sum two values which also live in the summary
    band. These two values are of type TppDBCalc and TppDBText:

    ftr_Total.Value:= ftr_Subtotal.Value + ftr_Freight.FieldValue;

    Unfortunately, if I use the veTraversal for the CalcType property,
    ftr_Subtotal.value is ALWAYS zero. That is why I favored the veReportEnd
    CalcType, since ftr_Subtotal.value is assigned by that time.

    In summary, I have not found a suitable strategy for having a TppVariable
    sum a TppDBCalc and TppDBText. A tradeoff exists between the CalcType used
    for the TppVariable and the calculated value of the TppDBCalc.

  • edited May 2005
    Hi Tyler,

    If I understand correctly, you are adding the total sum of one column in
    your database to the last record in a different colunm? In my testing the
    following method worked correctly.

    1. Create three TppVariables, one located in the detail band and two in the
    summary.
    2. Inside the OnCalc of the first variable in the detail band, update the
    value of the second variable with the sum of the data field.
    3. Inside the OnCalc of the second varible, add it's current total to the
    last record in your dataset.

    All three variables are set to reset on ReportEnd and calc on Traversal.

    Code...

    procedure TForm1.ppVariable1Calc(Sender: TObject; var Value: Variant);
    begin
    ppVariable2.Value := ppVariable2.Value +
    ppReport1.DataPipeline['AmountPaid'];
    end;

    procedure TForm1.ppVariable2Calc(Sender: TObject; var Value: Variant);
    begin
    ppVariable3.Value := Value + ppReport1.DataPipeline['AmountPaid'];
    end;

    --
    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.