Topic: How to add a Variable to a Fastreport?

Hi to all,
The manual of Fastreport says that this should work:

var

 Variable: TfrxVariable;

Variable := frxReport1.Variables.Insert(1);
// or alternative    Variable := frxReport1.Variables.add;

Variable.Name := 'My Variable 1';
Variable.Value := 10;

When I try this I get only an Errormessage.
Any other way to add variables to a report, I don't want to have in the database?
Its for cash box reports. The Variables will show the Report start date and Report end date.
Thank you for help.

Post's attachments

Attachment icon 1.png 10.23 kb, 28 downloads since 2017-05-04 

Re: How to add a Variable to a Fastreport?

Hello.


You can use variables if you create report by script, an example:

Post's attachments

Attachment icon Report variables.zip 10.35 kb, 110 downloads since 2017-05-05 

Dmitry.

Re: How to add a Variable to a Fastreport?

Dear Dimitry,
thank you for the information.
Does this work only for datasets or also for single values/variable?
The attached demo shows how to work with different datasets which means results of SQL Queries.
Thank you.

Re: How to add a Variable to a Fastreport?

teco049 wrote:

Dear Dimitry,
thank you for the information.
Does this work only for datasets or also for single values/variable?
The attached demo shows how to work with different datasets which means results of SQL Queries.
Thank you.

Another example for you

Post's attachments

Attachment icon Report variables_simple.zip 8.4 kb, 113 downloads since 2017-05-05 

Dmitry.