Equinox Online Help - Language Reference - A to Z

Home

CountRecords

Applies to
SyntaxCountRecords(TableName [, Identifier])
Action[Function] Performs a record count.
ScopeUsable anywhere
Notes

This function can operate in one of two modes, depending on the value of the argument Identifier. Identifier can either be AllRecords, or AllChildren. It defaults to AllRecords if omitted.

If Identifier is AllRecords, then the total number of records in the specified table, TableName, is returned. If Identifier is AllChildren, the number of child records in TableName for the current parent record is returned. ie To count the number of child records for a particular record, you need to specify the name of the child table (because their may be more than one child table). If an error occurs, an error number is stored in the system workarea SysError.

CategoryRecord location
See Also CurrentTableName, FindRecord, FindRecordLock, GroupFindRecord, IsLookup, IsRecord, IsSameRecord, Lookup, LookupWrite, SameRecord
Example

This example counts all records in the Customer table and displays the result on a message dialog.

Message CountRecords(customer, AllRecords)

The next example prints each customers name and their number of orders, in the Print window.

subtable customer
SetIndex DefaultIndex
FirstRecord

while not syserror
Print CustName, CountRecords(order, AllChildren)
NextRecord
end while
end subtable | customer