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

Variables in the footer and summary

edited February 2002 in General
I am trying to create a report like the following and need some help

I have a loan that has N payments. I have grouped by loan # and in the group
footer I want to show the only the last balance for that loan. Then in the
summary I want the total of the values shown in the group footer (i.e the
sum of all the last balances for all loans). The detail band is not visible.

Currently I have variable (varBalance) in the group footer to try and get
the last balance. But I just do this by setting its OnCalc to

Value:= plLoans['Balance'];
GTBalance := GTBalance + Value

I then have a variable in the summary with its OnCalc set to

Value := GTBalance

GTBalance is a Global variable that I declared to keep the running total of
the footer value.

The problem is i can not seem to get the right value appearing in both the
footer and summary variables. I have tried working with the timing on
varBalance to calculate on the group but I have not had any success. Mabey I
am not getting the last balance value correctly or I am having trouble with
the timing?

Thanks
Ian

Comments

  • edited February 2002
    Hi,

    one way would be to create the report with a Stringlist. Within the
    before print event of the group footer put the current sum value into
    the string list. Within the beforegenerate event of the summary band sum
    all values contained within the stringlist and write the result to a
    ppVariable.

    e.g.

    groupfooterbeforeprint
    // if your report is two pass save the count within the first pass of
    // the report
    if ppReport1.FirstPass and (StringList.Count =
    ppReport1.Groups[0].BreakNo) then
    begin
    Add the value to list (ppReport1DBCalc1.Value (dcSum))
    end;

    summaryband before generate
    // if second pass report use the second pass
    if ppReport1.SecondPass then
    begin
    ppVariable2.Value:= 0;
    for i:= 0 to Stringlist.Count - 1 do
    ppVariable2.Value:= ppVariable2.Value +
    Stringlist.Value;
    end;

    enjoy,
    Ron.

  • edited February 2002
    One other approach is to use the OnCalc from the detail band in the
    subreport to update all of the variables in the report. In RAP, you'll need
    a global variable handle to do this from the subreport.

    Set the variable timing to be OnTraversal, not OnDataPipelineTraversal.


    procedure TForm1.vblDetailValueCalc(Sender: TObject; var Value: Variant);
    begin
    {display the total in the summary band}
    vblSummaryTotal.Value := vblSummaryTotal.Value + 1;

    {display the new total}
    Value := vblSummaryTotal.Value;
    end;


    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.