Add a function field with a script to a report

Using a script, you can perform programming within a function field. For this, you use a function field of the Expression type.

You can also program within the report as a whole, for example for operations in sections other than the Detail section.

To use an If Then Else statement in a function field:

You can use an If Then Else statement in a function field. This looks as follows:

If {Veld} [=, <>, >, <, >=, <=] Waarde Then

   Result = WAAR

Else

   Result = ONWAAR

End If

Explanation:

{Field}: this can be a data field (a field from the data collection), but it can also be a function field.
[=, <>, >, <, >=, <=]: one of these operators can be used.
value: if the value is text, then it must be between double quotes (for example: Article). If the value is numerical, do not use double quotation marks (for example: 10). If the value originates in a check box, use True or False (for example: True).

TRUE: This is the result if the condition is met. This can be a data field or a function field, but also a value you select (for example a text).

FALSE: This is the result if the condition is not met. This can be a data field or a function field, but also a value you select (for example a text).

Example:

If {Element: Vinkveld}.Value = True Then

   {Element: Functieveld}.Value = "Ja"

Else

   {Element: Functieveld}.Value = "Nee"

End If

To use nested If Then Else statements:

In a function field you can also use nested statements. This looks as follows:

If {Veld} [=, <>, >, <, >=, <=] waarde Then

   Result = WAAR
Else

   If {Veld1} [=, <>, >, <, >=, <=] waarde1 Then

      Result = WAAR1

   Else

      Result = ONWAAR1

   End If

End If

Note:

If decimal or numerical fields are used in the above text, it makes sense to create separate function fields for this first and define the formatting of these fields there.

To use empty function fields to determine a value later on:

The value of a field may not be known until the moment a section is printed or formatted. In that case, it makes sense to put this value in an Empty function field. Create a function field and enter the value 0 (a function field always has to have a value). Then scripting can be added to the Create layout or Print event.

Directly to

  1. Function fields in reports
  2. Add function fields to reports
  3. Add function fields with a calculation to a report
  4. Combine text using an expression
  5. Add a script
  6. Add a text block
  7. Add a constant