Language:


Using Variables and Formulae - Assigning a Value to a Variable

The next step is to 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, the variable will count the number of Customers in the report. Therefore the incrementation should be linked to the Contact register, so that the value of the variable increases by one each time a Customer is printed.
  1. Click on the line in the report display area marked "Register: Contacts..." to select the Contact register. Code that is placed in this section is used once for each Customer 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.

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

  3. Enter the code to increase the value of the variable by one each time a Customer is printed in the report. This is done by specifying that the new value of the variable is to be its previous value plus one. The = sign assigns the new value to the variable.

  4. 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.
Please click the links below for more details about: