473,698 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recordcount only equals 1

Problem with this statement:
sSQL = "SELECT * FROM Projects;"
Set oDbe = CreateObject("D AO.DBEngine.36" )
oDbe.SystemDB = "myworkgrupfile .MDW"
Set oWS = oDbe.CreateWork space("", "me", "")
Set oDB = oWS.OpenDatabas e("mydb", , True)
Set oRs = oDB.OpenRecords et(sSQL)
Debug.Print oRs.RecordCount

It only returns 1 record.

But if I change this line to
Set oRs = oDB.OpenRecords et("Projects", dbOpenTable),
I get all my records. What is it about this db that would cause this?

thanks,
mjm

Nov 12 '05 #1
5 18165
RecordCount is not the number of records in a recordset, it is the number of
records that have been read from the recordset. It will only be guaranteed to
equal the number of records returned after a .MoveLast.

On Tue, 18 Nov 2003 13:33:15 -0800, michael montagne
<mm*******@walk ermacy.com> wrote:
Problem with this statement:
sSQL = "SELECT * FROM Projects;"
Set oDbe = CreateObject("D AO.DBEngine.36" )
oDbe.SystemD B = "myworkgrupfile .MDW"
Set oWS = oDbe.CreateWork space("", "me", "")
Set oDB = oWS.OpenDatabas e("mydb", , True)
Set oRs = oDB.OpenRecords et(sSQL)
Debug.Print oRs.RecordCount

It only returns 1 record.

But if I change this line to
Set oRs = oDB.OpenRecords et("Projects", dbOpenTable),
I get all my records. What is it about this db that would cause this?

thanks,
mjm


Nov 12 '05 #2
That's the ticket! Steve, I could kiss you.

Steve Jorgensen wrote:
RecordCount is not the number of records in a recordset, it is the number of
records that have been read from the recordset. It will only be guaranteed to
equal the number of records returned after a .MoveLast.

On Tue, 18 Nov 2003 13:33:15 -0800, michael montagne
<mm*******@walk ermacy.com> wrote:

Problem with this statement:
sSQL = "SELECT * FROM Projects;"
Set oDbe = CreateObject("D AO.DBEngine.36" )
oDbe.System DB = "myworkgrupfile .MDW"
Set oWS = oDbe.CreateWork space("", "me", "")
Set oDB = oWS.OpenDatabas e("mydb", , True)
Set oRs = oDB.OpenRecords et(sSQL)
Debug.Print oRs.RecordCount

It only returns 1 record.

But if I change this line to
Set oRs = oDB.OpenRecords et("Projects", dbOpenTable),
I get all my records. What is it about this db that would cause this?

thanks,
mjm



Nov 12 '05 #3
Aw shucks - lots of folks here could have answered that one. Glad I could
help though, and good seeing you here.

On Tue, 18 Nov 2003 16:52:23 -0800, michael montagne
<mm*******@walk ermacy.com> wrote:
That's the ticket! Steve, I could kiss you.

Steve Jorgensen wrote:
RecordCount is not the number of records in a recordset, it is the number of
records that have been read from the recordset. It will only be guaranteed to
equal the number of records returned after a .MoveLast.

On Tue, 18 Nov 2003 13:33:15 -0800, michael montagne
<mm*******@walk ermacy.com> wrote:

Problem with this statement:
sSQL = "SELECT * FROM Projects;"
Set oDbe = CreateObject("D AO.DBEngine.36" )
oDbe.SystemD B = "myworkgrupfile .MDW"
Set oWS = oDbe.CreateWork space("", "me", "")
Set oDB = oWS.OpenDatabas e("mydb", , True)
Set oRs = oDB.OpenRecords et(sSQL)
Debug.Prin t oRs.RecordCount

It only returns 1 record.

But if I change this line to
Set oRs = oDB.OpenRecords et("Projects", dbOpenTable),
I get all my records. What is it about this db that would cause this?

thanks,
mjm



Nov 12 '05 #4
no****@nospam.n ospam (Steve Jorgensen) wrote in
<5s************ *************** *****@4ax.com>:
RecordCount is not the number of records in a recordset, it is the
number of records that have been read from the recordset. It will
only be guaranteed to equal the number of records returned after a
.MoveLast.


Well, it can only be guaranteed to be accurate after a .MoveLast --
it may very well be accurate before that point:

1. if the recordset returns 0 records, the recordcount will always
accurately reflect that, even without the .MoveLast.

2. if there is only one record, it will be correct.

I don't rely on .RecordCount for anything except to see if there
are records returned by a recordset. If I want a count of records,
I do a Count() query.

It's only occasionally that I'll open a recordset for one purpose
and also use it to get a count of records. And that's only when I'm
using the recordset for some other purpose already.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #5
On Thu, 20 Nov 2003 01:56:55 GMT, dX********@bway .net.invalid (David W.
Fenton) wrote:
no****@nospam. nospam (Steve Jorgensen) wrote in
<5s*********** *************** ******@4ax.com> :
RecordCount is not the number of records in a recordset, it is the
number of records that have been read from the recordset. It will
only be guaranteed to equal the number of records returned after a
.MoveLast.
Well, it can only be guaranteed to be accurate after a .MoveLast --
it may very well be accurate before that point:


Thus, my use of "only guaranteed to be". Of course, not knowing if its
accurate is scantly better than knowing it's inaccurate.

1. if the recordset returns 0 records, the recordcount will always
accurately reflect that, even without the .MoveLast.

2. if there is only one record, it will be correct.

I don't rely on .RecordCount for anything except to see if there
are records returned by a recordset. If I want a count of records,
I do a Count() query.

It's only occasionally that I'll open a recordset for one purpose
and also use it to get a count of records. And that's only when I'm
using the recordset for some other purpose already.


If the recordset is a non-forwardonly snapshot (meaning it's a result suitably
small for a snapshot), I'll often use it for counting as well as for reading
rows. That's about the only time.
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5069
by: Jeff Boyer | last post by:
Hello everyone, Can someone tell me why a ADO recordset.recordcount would return a -1? I have confirmed that it has records in it by writing some values to the screen. Why can't I count the number of records returned though? Please help, Jeff P.S. I am using VBScript for my code connecting to a SQL Server 2000 database
12
2970
by: scott | last post by:
In LISTING 2, I have a SPROC that returns a recordset and a recordcount in SQL QA. I can access the Recordset with no problem. How can I grab the Recordcount with ASP code at the same time I'm getting the Recordset? In QA, the RecordCount displays below the Recordset. The below USAGE code will display my SPROC results. USAGE: EXEC SELECT_WITH_PAGING 'CustomerID, ShipName', 'OrderID', 'Northwind.dbo.Orders', 3, 10, 1, '', 'OrderDate'...
4
4881
by: don.fleming | last post by:
Hi folks: Am doing a VBA SQL Select stmt with multiple rows found and not getting RecordCount > 1. I've verified there are multiple rows found by copying my SQL stmt from Debug window and pasting it to a query - retrieves many rows. I need to program to handle many Rows in VBA. Suggestions much appreciated! Here is an excerpt of my VBA code after the SQLstmt is built: Debug.Print SQLstmt Set RecSet1 = SQLtbl.OpenRecordset(SQLstmt)
2
2135
by: Andy_Khosravi | last post by:
This is probably one of the most simple things to do in VB, yet somehow I've messed it up and cannot get it to work properly. I've used it dozens of times in the past, but for whatever reason I cannot get it to work today. I've studied both my old and new code and cannot see a reason why it's doing what it is. I've been hammering my head against the wall for three hours now playing around with ever simplified versions of the code to try...
10
6725
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that contains only tables. I have linked the tables for the front end to the back end database. I am trying to set the recordsource of a form to a query established by the user to narrow the scope but I don't want to display the form if there are no...
2
2162
by: rajvbprogramer | last post by:
here is my problem. i have two records. one containing 20 records and second containing 30 records. now i want the recordcount property to use and go to the 21 record. i m calculating the recordcount of both the record. now i m doing this a = rs.recordcount b = rs1.recordcount for x = b+1 to a
10
105187
by: r035198x | last post by:
The Object class has five non final methods namely equals, hashCode, toString, clone, and finalize. These were designed to be overridden according to specific general contracts. Other classes that make use of these methods assume that the methods obey these contracts so it is necessary to ensure that if your classes override these methods, they do so correctly. In this article I'll take a look at the equals and hashCode methods. ...
1
2478
by: qqmbers | last post by:
May be it will help someone. I faced the strange problem with RecordCount property of cloned Recordset within the Current event handler. The RecordCount value was correct every time I had diagnostic message boxes turned on or when I debugged the handler step by step. And these values became incorrect in normal mode (to be exact they became wrong after the first occurrence of "no records" case). I tried to use MoveFirst and MoveLast...
3
11065
by: sparks | last post by:
Is recordcount a little messed or what? For Each tdf In dbs.TableDefs If Left(tdf.Name, 3) = "tbl" Then Debug.Print tdf.Name Debug.Print tdf.RecordCount it prints the correct name but the RecordCount is off on 8 out of 30 tables. the only thing is all the correct ones don't have any records LOL
0
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.