473,657 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.OpenRecordse t("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 2132
An***********@b cbsmn.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.OpenRecordse t("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
10400
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 = Server.CreateObject("ADODB.Connection") objConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:\Inetpub\wwwroot\spruce.mdb;" strQuery = "SELECT * FROM schedule" Set rst = Server.CreateObject("ADODB.recordset")
4
4968
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. Here's the code (I have left out the details for the connection string): ------------------- strSQL = "SELECT * from orders" strConnect = Set osRecordSet = Server.CreateObject("ADODB.Recordset") osRecordset.Open strSQL, strConnect
2
5068
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
2967
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'...
1
2403
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 items), then use the total number of daily open items to calculate the percentage to all open items for the month. my first question is how would i be able to capture the current filtered openrecordset and count the records? would i use the
16
1772
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 System.Data.SqlClient.SqlDataAdapter(sql, conn) Dim ds As New DataSet() da.Fill(ds) ComboBox1.DataSource = ds.Tables(0) ComboBox1.DisplayMember = "Lender" da.Dispose()
10
6721
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
2161
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
1
2477
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...
0
8743
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
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
8622
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
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
4173
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...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
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
1973
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.