Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

"Rowset does not support fetching backward"

Posted on 2007-11-27
4
Medium Priority
?
1,294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses

609 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