Solved

Database question

Posted on 1998-09-04
2
128 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 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