Problem: Recordset count property always returns -1
The recordset class has a count property that is populated internally with the number of records in the recordset. Sometimes this count property contains the value '-1' even when the recordset has records.
Recordsets returned by the SearchExpression method will always have a count value of '-1'. This is a known issue.
The same is true for the SearchShape and SearchByDistance methods if the third argument 'expression' is used with anything other than a null string.
Solution or Workaround
Use the Statistics object to accurately count the number of records.
This is a Visual Basic example:
Set recs = aMapLayer.SearchExpression("AFIELD = 'AVALUE'")
Dim stats As MapObjects2.Statistics
Set stats = recs.CalculateStatistics("FeatureID")
MsgBox "The number of records is: " & stats.Count