[AccessD] .Recordcount returns -1?

Jim DeMarco Jdemarco at hshhp.org
Thu Jul 10 08:51:03 CDT 2003


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

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


***********************************************************************************
"This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited.  If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message.  Thank You".
***********************************************************************************



More information about the AccessD mailing list