?
Solved

Database question

Posted on 1998-09-04
2
Medium Priority
?
133 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
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 150 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

850 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