Solved

"Rowset does not support fetching backward"

Posted on 2007-11-27
4
1,270 Views
Last Modified: 2013-12-25
Hi,

The following snippet of code results in error "Rowset does not support fetching backward", in particular the .MoveLast line.

Does anybody see why?

The 2 key elements I am after here are 1) setting the CursorType to adOpenStatic in order to have the RecordCount be set, and 2) use CopyFromRecordSet (b/c I find it very convenient)

Thank you in advance for your advice.

Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.CursorType = adOpenStatic
   
    With rs
        .ActiveConnection = cn
        Dim sql As String
        .Open "exec sproc " 'sql
        Sheet4.Range("A" & CStr(FIRST_ROW)).CopyFromRecordset rs
        .MoveLast
        recCnt = rs.RecordCount
        ' MsgBox "Rec Cnt " + CStr(rs.RecordCount)
        .Close
    End With
   
    cn.Close
    Set rs = Nothing
    Set cn = Nothing

Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    rs.CursorType = adOpenStatic
    
    With rs
        .ActiveConnection = cn
        Dim sql As String
        .Open "exec sproc " 'sql
        Sheet4.Range("A" & CStr(FIRST_ROW)).CopyFromRecordset rs
        .MoveLast
        recCnt = rs.RecordCount
        ' MsgBox "Rec Cnt " + CStr(rs.RecordCount)
        .Close
    End With
    
    cn.Close
    Set rs = Nothing
    Set cn = Nothing

Open in new window

0
Comment
Question by:DotTheBug
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20361393
>        Sheet4.Range("A" & CStr(FIRST_ROW)).CopyFromRecordset rs
will consume your recordset.
you probably don't need the .movelast at all...

0
 

Author Comment

by:DotTheBug
ID: 20366793
CursorLocation = clientSide did the trick.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 21638908
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question