Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Recordset RecordCount Problem

Status
Not open for further replies.

vedicman

Programmer
Sep 5, 2003
128
US
When I run a query that contains SELECT DISTINCT or GROUP BY, the RecordCount displays as -1 when using the code below. If SELECT DISTINCT or GROUP BY are not used in the query, then the RecordCount displays the correct number.

Set myRs = New ADODB.Recordset
With myRs
.ActiveConnection = cn
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open (sSQL)
.RecordCount
End With

Any ideas what the cause or solution might be?

Thanks.....Franco
 
Don't trust the .RecordCount property of ADO recordsets. If you really need a count, do a select count() ... Here's some info/opinions thread709-1052131, but do search, as there are lot of info on this on the net ...

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top