473,383 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Listing Record Count Each Database Table

Hi,

I am doing database documentation and run the procedure below to list
the record count for each table in the database. The results in the
immediate window only a partial listing of tables. It appears the
ones missing are linked (ODBC) tables.

Any help you can lend would be appreciated.

- Henry

++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++

Sub RecordCounts()

''''''''''''''''''''''''''''''''''''
' Purpose: Count total records in each database table
''''''''''''''''''''''''''''''''''''

Dim db As DATABASE
Dim tdf As TableDef

Set db = CurrentDb

For Each tdf In db.TableDefs
Debug.Print tdf.Name & "/" & tdf.recordcount
Next

Set db = Nothing

End Sub
Nov 13 '05 #1
1 5649
"Henry Stockbridge" <hs***********@hotmail.com> wrote in message
news:29**************************@posting.google.c om...
I am doing database documentation and run the procedure below to list
the record count for each table in the database. The results in the
immediate window only a partial listing of tables. It appears the
ones missing are linked (ODBC) tables.

Any help you can lend would be appreciated.

- Henry


Try this:
Private Sub Command14_Click()
Dim db As Database, RS As Recordset
Dim tdf As TableDef
Set db = CurrentDb
For Each tdf In db.TableDefs
Set RS = db.OpenRecordset(tdf.Name, dbOpenDynaset)
On Error Resume Next
RS.MoveLast
Debug.Print tdf.Name, RS.RecordCount
On Error GoTo 0
Next
End Sub

For linked tables you must reach the last record
to have .RecordCount reading correctly records
number.
For this you use RS.MoveLast but must
trap error raised when a table doesn't
contain records.

Ciao
Bruno
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: yvan | last post by:
Approximately once a month, a client of ours sends us a bunch of comma-delimited text files which I have to clean up and then import into their MS SQL database. All last week, I was using a Cold...
6
by: 6thirty | last post by:
Hi, I've created a stocktaking database using Access XP. This is indexed by two fields - part number and shelf location. I am currently inputting all the data via a form. When I have entered a...
1
by: Scott269 | last post by:
So I've got an old MS Works database I imported into Access. I needed a primary key so I created a record number field that was just the record number I manually inserted when I entered it in the...
0
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a...
1
by: Roy Gourgi | last post by:
Hi, I am using VS.NET 2003 and I have made a connection to a MS Access database using the Server Explorer. Is this connection permanent, meaning that it will be there every time I reopen my...
20
by: Bryan | last post by:
hello all... im trying to add a record to an sql db on ms sql server 2000, using vb.net. seems to be working.. except for one thing, one of the columns in the database is a bit datatype, and...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
4
by: corey11 | last post by:
I'm a very low-level developer with limited VB knowledge but nonetheless was able to put together a very user-friendly and extremely helpful Access 97 database for my company some 10 years back. We...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.