[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2002-04-25
3
Medium Priority
?
133 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
[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
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 200 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

Technology Partners: 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 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