473,624 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Recordse tClone
rst.Requery ' This is the "magic" that helped
trec=rst.Record Count
Jan 25 '08 #1
1 2474
I would normally use both
------------------------------
Set rst=Me.Recordse tClone
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******** *************** ***********@v46 g2000hsv.google groups.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.Recordse tClone
rst.Requery ' This is the "magic" that helped
trec=rst.Record Count

Jan 28 '08 #2

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

Similar topics

6
10395
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
4967
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
5
16838
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
2966
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'...
3
5948
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 Conn=server.createobject("adodb.connection") Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & dbname sql = "SELECT * FROM Zips Where zipcode = '"& Request("zip") & "'"
2
2011
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 to obtain the value which works. What I need assistance with is the best method to use to ensure that only ONE customer number can be entered. A quick attempt to structure a piece of code is shown below. Any assistance will be appreciated. Thanks,...
1
2246
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 details. I also have a textbox called status in subform. When a passanger's details are entered, status value is set to "confirmed", when passanger calls in to reconfirm flight, status value changes to "Reconfirmed", and when passanger calls in to...
1
3293
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 Datasheet form; if without branch, a message will prompt if they want to add a branch. If a firm the users looking for is not on the list, they can type it on the Combo Box and it will be added on the firm table, then a message will prompt if...
1
5099
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 no experience at all in excel or the vb code to access excel. I found a few lines of code by searching on how to sort in vb for excel and the code with the new sort logic works fine the first time you run it, but run it twice and you get the titled...
0
8614
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
8330
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
8471
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...
0
7153
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...
1
6107
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
5561
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();...
1
2603
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
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.