Search Results for

    Show / Hide Table of Contents

    Passing a variable value in the TfrxReport.OnGetValue

    The last way to pass a value to a report is to use TfrxReport.OnGetValue event handler. This way is convenient in case you need to pass a dynamic value (that may change from record to record). Two previous ways are useful to pass static values.

    Let's look at example of using that way. Let's create the report and lay the "Text" object to it. Type the following text in this object:

    [My Variable]
    

    Now create the TfrxReport.OnGetValue event handler:

    procedure TForm1.frxReport1GetValue(const VarName: String; 
      var Value: Variant);
    begin
      if CompareText(VarName, 'My Variable') = 0 then
        Value := 'test'
    end;
    

    Run the report and we will see that variable is shown correctly. The TfrxReport.OnGetValue event handler is called each time when FastReport finds unknown variable. The event handler should return a value of that variable.

    Back to top © Copyright Fast Reports Inc.