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

Setting Value of a TppVariable to a String causes Error

edited May 2005 in RAP
I am trying to set the value of a TppVariable to a string from another
variable. When I do this I get an invalid variant type error. I have
attached an example program demonstrating the error. Unzip the attached
file into a directory. Open Project1 and Unit1. If you double click on the
report object you will see a simple report design. Both the main report and
the sub report have a variable object on them. On the calc tab of the main
report there is a variable declaration and an onCreate event. The Variable
declaration defines a TppVariable called TmpVar. The onCreate event sets
TmpVar to the Variable object on the main report. On the onCalc event of
the variable object on the sub report the following line is placed: This
should
TmpVar.Value := 'String to Display';

This should display 'String to Display' in the Variable object on the main
report but instaid an invalid Variant Type error is displayed. The variable
has a data type of dtString so it should be able to display it. Any help
would be appreciated.

Thanks,

Richard Gostin

Comments

  • edited May 2005
    Hi Richard,

    You need to be sure the DataType property of the TppVariable is set to
    dtString in order to set the value to a string type. This can be done at
    design time in the Delphi Object Inspector or in the report designer by
    clicking on the variable and setting the type using the combo box at the top
    left corner of the window. This can also be done at runtime by adding
    ppTypes to your uses clause.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2005
    Hi Nico,

    The Datatype is set to dtString. Actually if I use the onCalculate event of
    the variable I am setting to set the Value it works fine. It is just when I
    try to set the Value of one variable from another variables onCalculate.

    Thanks,
    Richard Gostin

  • edited May 2005
    Hi Richard,

    You seem to have uncovered a bug :). As a workaround, try using the
    TppVariable.AsString property instead of the TppVariable.Value property to
    set the string value. In my testing this worked correctly.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited May 2005
    This works perfectly. Thanks.

This discussion has been closed.