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
Solved

Recordset.Recordcount = -1 ??????

Posted on 2002-04-25
3
128 Views
Last Modified: 2010-05-02
Hi!

I make a query into a recordset. It isn't Nothing, but when I pick it's RecordCount, it always returns with -1.

Why?

  strSQL = "Select * from Table"
 
  Set guestBookData = New ADODB.Recordset
 
  guestBookData.Open strSQL, conn
 
  c = guestBookData.RecordCount
  MsgBox c

--------------------
c = -1, but rs isn't empty, I can get the data from it.
0
Comment
Question by:holdkoros
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 50 total points
ID: 6968177
That is because the default options on recordset.open is a ForwardOnly recordset, use:

guestBookData.Open strSQL,conn,adOpenStatic,adLockReadOnly

For a scrollable recordset, optionally set the cursorlocation to clientside.

guestBookData.CursorLocation = adUseClient

Before opening the recordset.
0
 
LVL 1

Expert Comment

by:gron
ID: 6968179
When you work with linked TableDef objects, the RecordCount property setting is always –1.
Using the Requery method on a Recordset object resets the RecordCount property just as if the query were re-executed.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6968188
gron, that is DAO stuff you are talking about, ADO is a different beast (similar in some respects but not the same).
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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