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

Calculated value in a label

edited February 2004 in General
I want to put a calculated value in a Label. I have been able to do this by
assigning the Caption a Value in the Band's BeforePrint event. Is there a
way to assign the Caption in one of the Label's Events? Should I be using a
Variable? I tried using a Variable but don't know what should be on the
left side of the assignment statment...

Just starting out..

Comments

  • edited February 2004
    PS
    I tried the following and get a runtime error of '..invalid variant.. The
    Variable's data type is 'dtstring'.

    procedure TForm1.ppVariable1Calc(Sender: TObject; var Value: Variant);
    begin
    value.asString := 'This is a test';
    //FItem.Name(tblReport.fieldbyname('item').asString);
    end;

  • edited February 2004
    Hi Rob,

    You are correct, using the OnCalc event with a TppVariable is much safer
    than using a TppLabel. When you place a TppVariable on a report, you can
    edit it's datatype by using the combo box in the Designer toolbar. If you
    have this set to "String" you should not have to use Value.AsString. Simply
    write:

    Value := 'I am a String";

    --
    Best Regards,

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