ADO Recordcount Problem

  • Thread starter Thread starter troytemp
  • Start date Start date
T

troytemp

Guest
I am using ADO with MS Access, but for some reason I am getting -1 when I use the recordcount property on a recordset. Do you have a code example to return the proper value. I cannot find anything on the Microsft site. I am not doing anything fancy...just trying to return the recordcount of employees from the employee table in Northwind. I suppose one option may be recordset.open "SELECT Count (*) from employees"

I don't want to use the DAO.recordset option as I want to do things in ADO now.


Thanks

Paul
 
Hello,

I just tried this out and it gave me the correct answer.
Private Sub testing()
Dim rst As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim strSQL As String
Set rst = New ADODB.Recordset
Set cnn = New ADODB.Connection
Set cnn = CurrentProject.Connection
strSQL = "SELECT * from tblBatting"
rst.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
Debug.Print rst.RecordCount
set cnn = nothing
set rst = nothing
End Sub


HTH
Robert

[This message has been edited by Robert Saye (edited 06-12-2001).]
 
Many thanks - it works.
 

Users who are viewing this thread

Back
Top Bottom