Is This Content Helpful?
We're glad to know this article was helpful.
Why do I always receive a value of -1 when I invoke the Count property on a recordset that I know contains records?
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