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

newbie: sum (field + calc)

edited May 2002 in General
Ok. I give up.

I have a dbCalc that summarizes a field in a sub report. Then I need to take
that SUM and add it to a regular DBfield's value (imagine the SUM of
purchase order line items added to a static shipping charge value).

Point me in the right direction- my variables don't seem to want to play
nice----

TIA-

kathy@fishertechnical.com

Comments

  • edited May 2002
    You should be able to assign the Value of your variable in the OnCalc event
    for the variable as follows...

    Value := MydbCalc.Value + MyShipChrg.Value;

    HTH,
    Mark

  • edited May 2002
    Create a variable component in the main report and set the data type.

    In the AfterGenerate event of the band containing the DBCalc, transfer the
    value of the DBCalc to the variable:

    ppVariable1.Value := ppDBCalc1.Value;

    That should do it...

    --
    Cheers,

    Tom Ollar
    Digital Metaphors Corporation
  • edited May 2002
    I think what I'm having trouble with is the next step.

    What I have: in the Detail band, under my subreport, is the
    SUM(EstExtPrice) -- totalling up the line items. Then I have the ppDBText
    field named SHIPPING.

    In the footer I have Variable 1 which has been assigned the SUM value,
    variable 3 which has been assigned the Shipping value, and Variable 2 which
    should be adding V1 + V3. The AfterGenerate code is good, but its still the
    calc of (Sum + field) that hangs me up. I've only been using this a few
    days, and this is the only thing I've been really stuck on. I'm sure it's
    something pretty straightforward and I'm just missing it. ( oh- The
    variables are all set to be dtcurrency, and I'm in professional version
    ReportBuilder on D6).

    ***********
    procedure TfrmEditPR.ppVariable2Calc(Sender: TObject; var Value: Variant);
    Var
    GrandTotal: Integer;
    begin
    //ppVariable2.Value := SHIPPING.FieldValue.asInteger;
    GrandTotal := SUM(ppVariable1.value + ppVariable3.value);
    end;

    procedure TfrmEditPR.ppDetailBand5AfterGenerate(Sender: TObject);
    var
    GetShip: Integer;
    begin
    GetShip := Shipping.FieldValue.asString;
    ppVariable1.Value := EstSUM.Value;
    ppVariable3.Value := GetShip;
    ppVariable2.value := SUM(ppVariable1.AsFloat+ppVariable3.AsFloat);
    end;
    ****************


  • edited May 2002
    Got it! Thanks everyone!
This discussion has been closed.