Frequently asked question

Why do I always receive a value of -1 when I invoke the Count property on a recordset that I know contains records?

Last Published: April 25, 2020


The Count property on a recordset may return a value of -1 when the recordset is derived from sources without 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.

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.

Article ID:000004297

  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic