Solved

Database question

Posted on 1998-09-04
2
129 Views
Last Modified: 2010-04-30
What's the easiest way to count how many items there is in a dbTable?
I know that I can use something like this:

Do While Not tblMyTable.EOF
      Items = Items + 1
      tblMyTable.MoveNext
Loop

But this takes to much time. Is there a better way?
0
Comment
Question by:Olli083097
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 50 total points
ID: 1433087
Try this (before you open the table):
Set tblMyTable = db.OpenRecordset("Select Count(*) As Cnt From dbTable")
nNumRecords = tblMyTable.Fields("Cnt")
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1433088
Depending on the type of table you open, you could also do this:

tblMyTable.MoveLast
tblMyTable.MoveFirst
nNumRecords = tblMyTable.RecordCount
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question