MapObjects Connection

 

Retrieving the correct number of records from a recordset

Applies to: MapObjects 1.x, 2.0

The Count property on a Recordset may return a value of -1 when the Recordset is derived from sources which do not contain header information such as an SDE layer, a Table object, or through a SearchExpression. 

To find the number of records in the resulting Recordset, create a Statistics object using the CalculateStatistics method on the Recordset. The Count property of the Statistics object contains the number of records.

Note: CalculateStatistics works on numeric fields only. You can use the FeatureId field, which exists for all Shapefile-based feature tables, if there are no other numeric fields in your feature table.  For example:

numRecs = myRecSet.CalculateStatistics("FeatureID").Count

This is discussed in the MapObjects 1.2 ReadMe file and in the MapObjects 2.0 'Count' Help topic, where an example is also provided.