Solved

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

Posted on 2002-04-25
3
130 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

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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 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…

730 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