Parameters
Parameter | Data Type | Description |
---|---|---|
Field | String | Field name. It can optionally contain a
qualified field name, for example MYFLD.MYENT . |
Return Values
- Value of Field in the next occurrence.
- Empty string (""), if there is no next occurrence.
Use
Allowed in all component types.
Description
The $next function enables you to refer to the contents of a field in the next occurrence. You can use it to:
- Copy contents of a field to another field or variable.
- Perform calculations.
- Make Boolean comparisons.
However, $next is not always the most efficient way of referring to a field in the next occurrence. This is particularly true when the referenced field is part of an occurrence that has already been active.
In this case, it is often preferable to store the contents of that field in a variable before moving to the next occurrence, then refer to the variable. This usually costs less processing power. Use the getFocus trigger to do this. Or, if you are printing, you could also use the leavePrinted trigger.
Setting a Page Break
The following example shows the use of the $next function to trigger a page break in a report:
trigger leavePrinted ; entity : INVOICE if (PAYDATE != $next(PAYDATE)) ; if next date different printbreak "DAYTOTAL" ; print totals for date eject ; force page break endif end
In this example, the DAYTOTAL break frame is printed and a page break forced after the last occurrence has been printed; if you want something else to happen after printing the last occurrence, you need to be able to test whether the next occurrence exists. Use the compare statement for this, which is usually faster..