The Peek function

Another tool we'll add to our collection in this set of data transformation techniques is the Peek function. The Peek function is an inter-record function that allows us to literally peek into previously-read records of a table and use its values to evaluate a condition or to affect the active record (the one being read).

The function takes one mandatory parameter, the field name into which we will "peek", and two optional parameters, a row reference and the table in which the field is located.

For example, an expression like:

Peek('Date', -2)

This expression will go back two records in the currently-being-read table, take the value on the Date field and use it as a result of the expression.

Or take this other expression:

Peek('Date', 2)

In this expression instead of "going back" two records, we will take the value in the Date field from the third record from the beginning of the current table (counting starts at zero).

We can also add a table name as the third parameter, as in the following expression:

Peek('Date', 0, 'Budget')

This expression will return the value that the Date field stores on the first record in the Budget table.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset