Posted on 2001-06-04
Last Modified: 2013-11-23

i am usin ado.With all typres of cursors it says rs.moveprevious says not allowed.

Set rs = conn.Execute("select * from customer", adOpenKeyset)

help me
Question by:kar_online
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

Expert Comment

ID: 6152100
What are you connecting to? (e.g. SQL Server, Access)
What are the properties of your connection and recordset?

Accepted Solution

mukunth earned 50 total points
ID: 6152104
The Execute method of the connection object returns a forward-only recordset.Use the above as:

rs.Open "select * from customer",adOpenKeySet

It will work as you want it to.

Expert Comment

ID: 6152109
Use this is faster and you can movelast

Dim ArrayRs()
Dim Rs As ADODB.Recordset
Set Rs = New ADODB.Recordset
    Rs.Open "select * from customer, Conn, OpenForwardOnly, adLockReadOnly
Set Rs = Nothing

This will make a 2d array

to get the first row and first col:var=ArrayRs(0,0)
to get the second row and first col:var=ArrayRs(0,1)
to get the third row and first col:var=ArrayRs(0,2)

to get the first row and second col:var=ArrayRs(1,0)
to get the second row and second col:var=ArrayRs(1,1)

To get number of row return:var=Ubound(ArrayRs,2)

Whit .GetRows You can move forward and backward by change the index of ArrayRs(?,?)

You can do something like this

For i=0 to Ubound(ArrayRs,2)
     debug.print ArrayRs(0,i) 'this will print all result for the first field of the table

Industry Leaders: 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!


Expert Comment

ID: 6152117
Comment to my last comment:

When i write
to get the first row and first col:var=ArrayRs(0,0)

col is the field number of your select

ex.:select userid, username


row is the result row


if the result is

userid name
______ ____
1      John
5      Paul

Row #1 is UserId# 1
Row #1 is UserId# 5

LVL 52

Expert Comment

by:Ryan Chong
ID: 6152201
Hi, check the EOF status.

Expert Comment

ID: 6152978
The problem could be related to your database ( I've had problems using .update and .delete when connecting to an AS/400 database). But try the follwing 2 things and see if either works (second solution will be slower!)

' Initialise
Dim RecSet As ADODB.Recordset
Set RecSet As New ADODB.Recordset  

'Open for dynamic read only navigation
RecSet.Open "Select * from customer", conn, adOpenDynamic, adLockReadOnly, adCmdText

'Check recordset contains something
If RecSet.EOF Then
   MsgBox("No records exist", vbOkOnly + vbInformation)
   Set RecSet = Nothing

' If .MovePrevious doesn't work here then try the following

' initialise integers
Dim RecCount as Integer
Dim RecNum as Integer

' store number of records in set
RecNum = RecSet.RecordCount

'store current record in set
RecCount = 1

'Use procedure to simulate MovePrevious
Call MovePrevious(RecSet,RecCount,RecNum)

'write procedure to simulate MovePrevious
Public Function MovePrevious(RecSet as ADODB.RecordSet,
                             RecCount as Integer,
                             RecNum as Integer)
Dim i as Integer

Select Case RecCount
   Case 1
      RecCount = RecNum
      Exit Function
   Case 2
      RecCount = 1
      Exit Function
   Case Else
      For i = 1 to RecCount - 1
      Next i
      RecCount = RecCount - 1
      Exit Function  
End Select

End Function



Expert Comment

ID: 6153114
you could use adOpendynamic instead of adOpenKeyset

Expert Comment

ID: 7025062
You have 14 open questions today that need your attention.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder, Mindphaser or I will return to finalize these as soon as possible if after 7 days no response by the Asker.  EXPERTS-->  please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.

To view your locked questions, please click the following link(s) and evaluate the proposed answer.

*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link 
------> POINTS FOR EXPERTS awaiting comments are listed in the links below (Part 1) (Part 2)
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
Thanks everyone.
Moderator @ Experts Exchange
LVL 49

Expert Comment

ID: 7132859
Hi kar_online,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept mukunth's comment(s) as an answer.

kar_online, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with my recommendation, please post an explanatory comment.
DanRollins -- EE database cleanup volunteer

Expert Comment

ID: 7167854
Comment from expert accepted as answer

E-E Moderator

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…

718 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