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

ppVariable + count

edited October 2003 in General
Hi
Do u know how can i implenents a count function with ppVariable that count
only when a field in the report have a value in it ( i am using
SuppreesRepatedValues)?

thanks

Sharon

Comments

  • edited October 2003
    Hi Sharon,

    You will need to use two TppVariables to accomplish this. Place one
    Variable in the detail band with your data and one where you would like to
    display your count. In the first variable's OnCalc event you will need to
    keep track of the dataset's current and old value to compare the two. When
    the value changes ie. the current and old are not equal to eachother,
    increase the second Variable's value. This should keep track of the count
    of the values without counting the repeated values. Below is a snip of code
    I wrote to do this.

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    FOld := 0;
    end;

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

    if FOld = 0 then
    FOld := ppReport1.DataPipeline['CustNo'];

    liCurrent := ppReport1.DataPipeline['CustNo'];

    if liCurrent <> FOld then
    begin
    ppVariable2.Value := ppVariable2.Value + 1;
    FOld := liCurrent;
    end;

    end;

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.