How to pass constant values to frxReport?

edited 8:15AM in FastReport 3.0
How can I pass constant values to a report?

I want to pass more info than provided by the ReportOptions: Author, Name etc.
I have this need, because I store report forms in the database to allow users to build their own reports. The extra information is fixed for the report upon starting, but variable for the application itself.
I have tried report.variables := 'xx'; This won't work.

Please help me out.

Comments

  • edited 8:15AM
    You need to surround what you are passing as a value with quotes.

    This is from the Programmer's Manual:

    <span style='color:blue'>
    You should be careful when assigning a string-type values to report variables. For example, the next code will raise exception "unknown variable 'test'" when running a report:

    frxReport1.Variables := 'test';

    because FastReport trying to calculate a value of such variable. The right way to pass a string values is:

    frxReport1.Variables := '''' + 'test' + '''';

    In this case the variable value - string 'test' will be shown without errors. But keep in mind that:

    - string should not contain single quotes. All single quotes must be doubled;

    - string should not contain #13#10 symbols.

    In some cases it is easier to pass variables using a script.
    </span>

    Link to the On-line documentation
  • edited 8:15AM
    hi...
    try this


    on the "GetValue" event of 'frxReport'

    procedure TFrmGeneral.frxReportGetValue(const VarName: String;
    var Value: Variant);
    begin

    if (VarName = 'Report_Variable_Name') then
    Value := 'Nemesis';

    end;


    Report_Variable_Name := This a variable created in your report.
    Nemesis := Value assigned to variable (in your case constant value)

    good look

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.