[AccessD] .Recordcount returns -1?

Bryan Carbonnell Bryan_Carbonnell at cbc.ca
Thu Jul 10 09:04:13 CDT 2003


adOpenDynamic cursor doesn't either, but adOpenStatic does.

I just fought with that this week.

Bryan Carbonnell
bryan_carbonnell at cbc.ca

>>> Jdemarco at hshhp.org 10-Jul-03 9:51:03 AM >>>
It also depends on the type of cursor.  adOpenForwardOnly won't return a record count while adOpenKeyset will.

HTH,

Jim DeMarco
Director of Product Development
HealthSource/Hudson Health Plan


-----Original Message-----
From: Mark H [mailto:Lists at theopg.com] 
Sent: Thursday, July 10, 2003 9:31 AM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] .Recordcount returns -1?


Ado returns -1 if it can't get the recordcount, or the provider or
cursor don't support recordcount. A real pain in the back side...

Mark

-----Original Message-----
From: accessd-bounces at databaseadvisors.com 
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Sad Der
Sent: 10 July 2003 14:13
To: Acces User Group
Subject: [AccessD] .Recordcount returns -1?


Hi,

those damn 2 years that i've been Oracle-ing...

I use a ADODB recordset in my A2K application. With
this recordset I get all date from a table. The table
has 1 record.

When I use the code below rst.Recordcount returns -1.
Why is that? MsgBox .Fields(0) returns 01/07/2003 So
it should pick it up.

What am i missing?

thnx in advance,
Sander

    Dim conn As ADODB.Connection        'db connection
    Dim rst As ADODB.Recordset          'recordset
returned by the query
    Dim strSQL As String
    
    Set conn = CurrentProject.Connection
    Set rst = New ADODB.Recordset
    
    strSQL = "SELECT date FROM tblActivity" 

    With rst
        .ActiveConnection = conn
        .Source = strSQL
        .CursorType = adOpenDynamic
        .Open
        .MoveLast
        .MoveFirst
        MsgBox .Fields(0)
    End With
        
    MsgBox rst.RecordCount





More information about the AccessD mailing list