Creating a Report Generator Report - Using Variables and Formulae - Assigning a Value to a Variable

This page describes using the [Code] button to assign a value to a variable. Before doing so, you must have "declared" the variable as described here.


After declaring a variable, you can assign a value to the variable. In the case of variables that count the number of records in a report or calculate totals, the value of the variable will accumulate as the report is printed. You should therefore take care to increment these variables at the correct time to ensure that they remain accurate. In the example Customer List that we are using in this documentation, we will use a variable to count the number of Customers in the report. Therefore we will link the incrementing to the Contact register, so that the value of the variable will increase by one each time a Customer is printed in the report. Follow these steps:

  1. Return to the Report Definition record and go to the 'Data' card.

  2. Click on the register line in the report display area (marked "Register: Contacts..." in the example) to select that register. Code that is placed in this section will be used once for each record that is printed. Make sure you do select the correct register as otherwise the code will be placed in the wrong section and therefore the variable will not contain the correct value.

  3. Click the [Code] button. The 'Code' dialogue box opens:

  4. Enter the code that will increase the value of the variable by one each time a record is printed in the report. To do this, specify that the new value of the variable is to be its previous value plus one. The = sign assigns the new value to the variable.

  5. Click the [OK] button to add the code to the Contact register section in the report display area:

    For more details about the syntax that you should use in the 'Code' dialogue box, please refer to the Syntax page.
Having assigned a value to the variable, please follow the links below for more details about:

Creating a Report Generator Report:

Go back to: