Solved

"Rowset does not support fetching backward"

Posted on 2007-11-27
4
1,262 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 142

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 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