473,396 Members | 1,722 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.

RecordCount method

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 combination, but it required the error handler for the "no
records" case. Then I tried to use EOF/BOF-based solution but these
properties behave in the same way. I solved my problem in the
following way - I just added invoke of Requery method just after
creation of recordset. For my case it looks like that:
Set rst=Me.RecordsetClone
rst.Requery ' This is the "magic" that helped
trec=rst.RecordCount
Jan 25 '08 #1
1 2451
I would normally use both
------------------------------
Set rst=Me.RecordsetClone
If Not rst.EOF Then
rst.MoveLast
rst.MoveFirst
intRecCount=rst.RecordCount
End If
---------------------------
I personally prefer not to requery as it can be slow on complicated queries
and/or larger tables.
I hope this RecordCount issue was fixed in Access2007.

<qq*****@gmail.comwrote in message
news:5b**********************************@v46g2000 hsv.googlegroups.com...
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 combination, but it required the error handler for the "no
records" case. Then I tried to use EOF/BOF-based solution but these
properties behave in the same way. I solved my problem in the
following way - I just added invoke of Requery method just after
creation of recordset. For my case it looks like that:
Set rst=Me.RecordsetClone
rst.Requery ' This is the "magic" that helped
trec=rst.RecordCount

Jan 28 '08 #2

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....
5
by: Samuel Hon | last post by:
Hi SQL Server 7.0 using stored procedures. I need to do a SELECT Top but I always need to find the record count for the entire SELECT statement. ID Name -- ---- 1 Abraham
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...
3
by: MikeR | last post by:
When I use the following, the RS.recordcount is -1. I also can't do a RS.moveprevious. What have I overlooked? Thanks, Mike dbname="DBQ=" & Server.MapPath("../db/my.mdb") set...
2
by: Dalan | last post by:
I have created a table and form for allowing the input of a unique customer number (not an ID autonumber number) which a customer would enter once after installing the database. I'm using DLookup...
1
by: Hasanain F. Esmail | last post by:
Hi All, I am using A2 for this database. I have a main form with bound fields of FlightNumber and FlightDate I also have a subform. This subform takes details of a passanger along with other...
1
by: Orchid | last post by:
Hello all, I have a Combo Box on a form with selection of a firm list. When the users select a firm from the Combo Box and if the firm has branch(es), a list of branch(es) of the firm opens in a...
1
by: Socko | last post by:
I'm trying to fix an sub routine in an VB module that basically reads in a MS database and writes it to an Excel Spread sheet. It works just fine except that the data isn't sorted correctly. I have...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
0
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...
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...
0
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,...

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.