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

sub totals and grand totals

edited November 2001 in General
Hi,

I am making a aging report as shown below and having problem printing
subtotals -
----------------------------------------------
group1
String1
group2
number1 date1
detail
number2 number3 number4
footer2
stotal1 stotal2 stotal3
footer1
summary
gtotal1 gtotal2 gtotal3
------------------------------------------------
The table is sorted on String1,number1,date1

The string1, number1,date1 are from a table while
depending on the difference between today and date1,
the number is printed either at number2 or number3 or number4, which are
variables

How do I get the subtotals and the grand total ?

Also I want to get the date1 of the first record of the group1 disregarding
the dates of other record of the same group.

Thanks

Mansoor

Comments

  • edited November 2001
    Use a TppVariable an code its OnCalc evnet handler to perform the
    calculations. It has a timing dialog (right-click over it in designer) where
    you can specify the timing that it fires and when it resets its value.
    You'll want to reset its value every time that the group ends. In the
    OnCalc event handlers of the variables in the detail band, you can increment
    the values of variables in the summary band to get the grand totals.

    In order to grab the first value of a group, use a boolean flag variable and
    the Group.AfterGroupBreak event. When the first detail band of the next
    group begins printing you can grab the first value from the datapipeline.
    The following code snippet uses a variable in the detail band to increment
    its value only when a new group starts, but it takes the same approach.


    procedure TForm1.Button1Click(Sender: TObject);
    begin

    FNewGroup := False;

    ppReport1.Print;

    end;

    procedure TForm1.ppGroup1AfterGroupBreak(Sender: TObject);
    begin
    FNewGroup := True;
    end;

    procedure TForm1.ppVariable1Calc(Sender: TObject; var Value: Variant);
    begin

    if FNewGroup then
    begin
    Value := Value + 1; {perform your date calculation here}

    FNewGroup := False;
    end;

    end;


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.