Solved

Database question

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now