Avatar of ANTHONY CHRISTI
ANTHONY CHRISTI
Flag for United States of America asked on

How can I find out the size of each table in my database

How can I find out the size of each table in my database
Microsoft AccessVBA

Avatar of undefined
Last Comment
ANTHONY CHRISTI

8/22/2022 - Mon
Scott McDaniel (EE MVE )

The only way to accurately determine the size is to export each table to a separate database, and compare before and after sizes.

You can estimate the size by determining the maximum size of each Field in each table, and then summing those to find the size of a "row", and then multiplying that by the number of rows in the table. This would give you a very rough estimate of the table size - but if you have Memo, Attachment or any other multivalued fields then you really can't use this method.
Scott McDaniel (EE MVE )

Also, there are some 3rd party utilities that do this, like Total Access Analyzer:

http://www.fmsinc.com/microsoftaccess/bestpractices.html
Saurabh Singh Teotia

You can use a freeware tool like this to do what you are looking for..

http://www.atroplan.com/AccMemReporter.htm

Or

http://www.fmsinc.com/microsoftaccess/documentation/reports/Table_SizeBySize.html

Saurabh...
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
PatHartman

Table size is also impacted by the number of indexes attached.  So, you would need to include a calculation for indexes in your estimate as well.
ANTHONY CHRISTI

ASKER
http://www.atroplan.com/AccMemReporter.htm works for .mdb formats.

Anybody aware of vba code that I can copy?
Jeffrey Coachman

Not sure how/where you need this data displayed, ...
But try code like this as a start:

Dim tdf As TableDef
Dim strRecCount As String

    For Each tdf In CurrentDb.TableDefs
        If Left(tdf.Name, 4) <> "msys" Then
          strRecCount = strRecCount & vbCrLf & "The table " & tdf.Name & " has " & DCount("*", tdf.Name) & " records"
        End If
    Next tdf

Note that code like this will take a while to run if you have a lot of tables with a lot of records

Let me know

JeffCoachman
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ANTHONY CHRISTI

ASKER
The table size cannot exceed 2GB, so I need to know that size not the record count.
ASKER CERTIFIED SOLUTION
Scott McDaniel (EE MVE )

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ANTHONY CHRISTI

ASKER
Divided the tables into separate databases and linked to each.  Problem is resolved.