Rated
Read 31,233 times
Related Categories
Count the number of records
You will probably have noticed that often the RecordCount method of the Data Control does not seem to work. The answer is that you need to goto the end of the records before it can tell you how many there are! Here's the code.
Data1.Recordset.MoveLast
Msgbox "Record Count: " & Data1.Recordset.RecordCount
James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.
Comments
-
I came across this topic and just wanted to add a bit to it.
In the case mentioned where you would only want to show 300 records if there were 500 or more, simply make a query and use it instead of...
Posted by mrjdesign on 18 Feb 2005
Start at the ID for the first one.
Do a regular loading of data and use the Move.next to get the next
Keep a counter in your code that increments for each record.
Load the data to your VB form or... -
Posted by tpowers on 13 Jan 2005
I am wondering is it possible to count the records in the database and then say ok no just display 300 records out the 500 records in a table. or is that not possible....I have been trying and trying ...
|