RECNO Function
Syntax
Arguments
- tablename
Optional. Default = current or primary table. The name of a table.
Description
Returns the record number of the current record.
Discussion
RECNO() returns the record number of the current record in the specified table.
Examples
A common requirement when you print reports is to print each record's physical record number in one of the columns. You can do this by defining a calculated field called NUMBER with the expression:
recno()
How to initially assign unique record numbers
To initially assign unique numbers to each record in a table, starting with any number (say, 1000), use the Update operation with the following update expression:
recno() + 1000
This expression creates a unique identification code for each composite record of a set:
"R" + ltrim( str( recno("Product") ) ) + ltrim( str( recno("Vendor") ) )
Note : Using the record number to create a unique record ID is not a good idea. The value returned by RECNO() is only a physical position in a table. It can change if you delete a record and then pack the table.
How to display the current record number
- 1
While your form is in design mode, click to create a calculated field.
- 2
Give the field a unique name.
- 3
In the Expression field enter RECNO().
- 4
Click OK to save.
- 5
Drag the new field from the Drag and Drop List onto your form.
See Also