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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RecordCount for Distinct

Status
Not open for further replies.

nightjam

Programmer
May 14, 2004
18
JM
I have a SQL returing distinct values. I need to know the total rows of the recordset.

How is this possible without iterate through the recordset and having a counter?

I tried the following code but it keeps giving me recordcoutn of -1

SQLquery="SELECT DISTINCT Elective FROM tblStudents"
DbrecordSet.Open SQLquery, Dbconnection, 2 , 3
DbrecordSet.moveLast
TotalUnits = DbrecordSet.recordcount
 
Try this
Code:
SQLquery="SELECT DISTINCT Elective FROM tblStudents"
DbrecordSet.CursorLocation = 3   [COLOR=black cyan]' Client side cursor[/color]
[COLOR=black cyan]' Open a KeySet Cursor type ... not a Dynamic cursor[/color]
DbrecordSet.Open SQLquery, Dbconnection, [red]1[/red] , 3    
DbrecordSet.moveLast
TotalUnits = DbrecordSet.recordcount
ADO Documentation said:
The cursor type of the Recordset object affects whether the number of records can be determined. The RecordCount property will return -1 for a forward-only cursor; the actual count for a static or keyset cursor; and either -1 or the actual count for a dynamic cursor, depending on the data source.
 
<RESOLVED>
Thanks. I understand. ALl ok. I need to
closed this thread as resolved.
 
I need to closed this thread as resolved.

TT keeps resolved threads around so that others can see the solution. Glad you got it sorted out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top