|
-
Dec 19th, 2005, 05:33 AM
#1
Thread Starter
Junior Member
Finding the Number of Rows
Hi, May i know after i open my database, what is the code for finding the number of rows in my table?
Set MyDatabase = DBEngine.OpenDatabase("C:\temp.mdb", True)
Set rcd = MyDatabase.OpenRecordset("tbl_Main")
rcd.MoveFirst
thanks in anticipation.
-
Dec 19th, 2005, 07:30 AM
#2
Addicted Member
Re: Finding the Number of Rows
Code:
rcd.MoveLast
numberOfREcords = rcd.recordcount
if you fail to plan, you plan to fail
-
Dec 19th, 2005, 05:57 PM
#3
Fanatic Member
Re: Finding the Number of Rows
I believe it is only reliable if the cursor is set to client... adUseClient, if you use the RecordCount property.
-
Dec 19th, 2005, 08:08 PM
#4
Thread Starter
Junior Member
Re: Finding the Number of Rows
Hi, thanks for the reply,
may i ask that what is the meaning of adClient?
could you elaborate on that?
thanks a lot.
-
Dec 19th, 2005, 08:15 PM
#5
Fanatic Member
Re: Finding the Number of Rows
EDIT: This is only for ADO, if your using DAO then none of my posts apply. And just use RecordCount normally as the other guy says.
It is a constant for ADO, maybe DAO as well not sure about DAO. But anyways, when your setting up your connection you indicate that you want the "cursor" to reside locally on your machine by setting the property. I actually forgot most of the reasons behind using a client side cursor.
VB Code:
Dim cn as ADODB.Connection
set cn = new ADODB.Connection
cn.CursorLocation=adUseClient
Like many things with programming it is a pearl of wisdom you once heard and forget where it came from.
-
Dec 19th, 2005, 09:36 PM
#6
Re: Finding the Number of Rows
You can always execute a sql statement to count the records too.
SELECT Count(*) As TotalRecs FROM Table1;
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|