473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

cant get recordcount property to work

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 and get it to work, but no dice.

The problem?

The recordcount property returns a value of "1" no matter what. It
doesn't matter if there are 3 records or 30,000, the recordcount
property returns a value of 1. The recordset does accurately show what
the first recordset contains, but never shows the other records.

The setup?
I tried moving my code around trying to isolate the problem before I
finally broke down and created a new sample database to insure there
were no other outside factors causing the problem.

*The application is made using Access 97
*1 table called "bugfix" which contains 3 records.
*there is one form with 1 button on it. The form contains the following
code:
***************************
Option Compare Database
Option Explicit

Private Sub Command0_Click()
DoIt
End Sub

Private Sub DoIt()
Dim rts As Recordset
Dim db As Database
Dim t As Long

Set db = CurrentDb
Set rts = db.OpenRecordset("SELECT * FROM bugfix")
t = rts.RecordCount
End Sub
***************************

Since the table 'bugfix' has 3 records, I would think that t should =
3.
It doesn't; it equals 1.

Why?

Thanks for any help in advance!

Nov 13 '05 #1
2 2118
An***********@bcbsmn.com wrote:
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 and get it to work, but no
dice.

The problem?

The recordcount property returns a value of "1" no matter what. It
doesn't matter if there are 3 records or 30,000, the recordcount
property returns a value of 1. The recordset does accurately show what
the first recordset contains, but never shows the other records.

The setup?
I tried moving my code around trying to isolate the problem before I
finally broke down and created a new sample database to insure there
were no other outside factors causing the problem.

*The application is made using Access 97
*1 table called "bugfix" which contains 3 records.
*there is one form with 1 button on it. The form contains the
following code:
***************************
Option Compare Database
Option Explicit

Private Sub Command0_Click()
DoIt
End Sub

Private Sub DoIt()
Dim rts As Recordset
Dim db As Database
Dim t As Long

Set db = CurrentDb
Set rts = db.OpenRecordset("SELECT * FROM bugfix")
t = rts.RecordCount
End Sub
***************************

Since the table 'bugfix' has 3 records, I would think that t should =
3.
It doesn't; it equals 1.

Why?

Thanks for any help in advance!


Try rts.movelast first to populate the recordset.
Nov 13 '05 #2
You are my hero.

Nov 13 '05 #3

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

Similar topics

6
by: Mark Watkins | last post by:
I know for a fact that in my database, I have three records under the users table. However when I execute this code: --------------BEGIN CODE---------------- Set objConn =...
4
by: Navin Kulshreshtha | last post by:
Hi folks, I'm opening a recordset with a SQL statement and then trying to use the .RecordCount property to count the number of rows in the recordset. For some reason, it is always returning -1....
2
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...
12
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...
1
by: JMCN | last post by:
hello- i have created a tabular form using records from a specific query. then users will filter out the specific data. the next step is to take the count of the current records (daily open...
16
by: Mike Fellows | last post by:
when i load my windows form i populate a combobox i use the code below Dim conn As New System.Data.SqlClient.SqlConnection(strConn) Dim sql As String = "AllLenders" Dim da As New...
10
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...
2
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...
1
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.