Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Table Sizes

Posted on 2013-12-04
14
Medium Priority
?
299 Views
Last Modified: 2013-12-04
How do I find the sizes of my Access 2010 tables?
0
Comment
Question by:Chuck Wood
[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
  • 5
  • 4
  • 3
  • +1
14 Comments
 
LVL 21
ID: 39696225
Size? Are you referring to record counts?

Try:

Dim tbl As TableDef
Dim db As Database
Dim tblCount As Long

Set db = CurrentDb()

For Each tbl In db.TableDefs
    
    If Left(tbl.Name, 4) <> "MSys" Then  'do not include system tables.
        tblCount = DCount("*", tbl.Name)
        Debug.Print tbl.Name; tblCount
    End If
Next

db.Close
Set db  

Open in new window

0
 
LVL 16

Author Comment

by:Chuck Wood
ID: 39696242
I want to determine each table's contribution to the size of the database.
0
 
LVL 13

Accepted Solution

by:
magarity earned 2000 total points
ID: 39696337
I found this script someone made that will tell you the sizes of the tables (at the bottom of the thread):
http://www.utteraccess.com/forum/Determine-Table-Size-t1938952.html

Access does not have any built in management tool that will tell you with just a few clicks.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 21
ID: 39696360
OK. There really is no built-in way to do this that I am aware of.

The most accurate way I have found is:

1) Create a new blank database
2) Close the database
3) Get the size of it empty.
4) Import a single table
5) Compact the database
6) Close the database
7) Get the size of the database and subtract the size when empty.

This can be automated with code:

Here is code for an MDB:
** Note is does not do the compact before getting the length

'---------------------------------------------------------------------------------------
' Procedure : ListAllTables_Size
' Author    : Gustav(original)
' Created   : 11/15/2009
' Purpose   : To get approximate sizes of all
'non-MSys tables in an Access mdb.
'Outputs table names and sizes  to immediate window.
'
'From AccessD discussion-
'---------------------------------------------------------------------------------------
' Last Modified:
'
' Inputs: N/A
' Dependency: Microsoft DAO 3.6 Object Library
'------------------------------------------------------------------------------
'
Public Sub ListAllTables_Size()

  Dim dbs As DAO.Database
  Dim tdf As DAO.TableDef
  
  Dim strName As String
  Dim strFile As String
  Dim strPath As String
  Dim lngBase As Long
  Dim lngSize As Long
    
   On Error GoTo ListAllTables_Size_Error

  Set dbs = CurrentDb
  strName = dbs.Name
  strPath = Left(strName, Len(strName) - Len(dir(strName)))
  
  ' Create empty database  to measure the base file size.
  strFile = strPath & "base" & ".mdt"
  CreateDatabase strFile, dbLangGeneral
  lngBase = FileLen(strFile)
  Kill strFile
  Debug.Print "Base size", lngBase
  
  For Each tdf In dbs.TableDefs
    strName = tdf.Name
    ' Apply some filtering - ignore System tables.
    If Left(strName, 4) <> "MSys" Then
      strFile = strPath & strName & ".mdt"
      Debug.Print strName,;
      CreateDatabase strFile, dbLangGeneral
      DoCmd.TransferDatabase acExport, "Microsoft Access", strFile, acTable, strName, strName
      lngSize = FileLen(strFile) - lngBase
      Kill strFile
      Debug.Print lngSize
    End If
  Next
  
  Set tdf = Nothing
  Set dbs = Nothing

   On Error GoTo 0
   Exit Sub

ListAllTables_Size_Error:

    MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure ListAllTables_Size "
  
End Sub

Open in new window




Editing records by adding data to a field can  cause a record to grow and use more space.  Not just by adding new records cause a table to grow.

Note: Unless every field in the table is filled to the max, every record will not use the same about of space.

To estimate the maximum size a table could use is possible if there are no memo fields or attachment fields.  You add up the max length of all the fields. Multiple that by the record.

Curious,  why do you need to know this?

TIP: The more we understand about what you are doing the better advice we can give.

Is your database split?
Is the  back end or un-split database getting over 1 GIG?
0
 
LVL 16

Author Closing Comment

by:Chuck Wood
ID: 39696380
That works perfecly. Thank you.
0
 
LVL 85
ID: 39696382
What's the end goal of this? Just curious, really, as your search, and HTC's suggestions, are about the only way to do this.
0
 
LVL 16

Author Comment

by:Chuck Wood
ID: 39696388
TheHighTechCoach: Sorry but magarity beat you to the solution.
0
 
LVL 16

Author Comment

by:Chuck Wood
ID: 39696396
LSMConsulting: My end goal is to find table sizes so I can determine where to archive data as several of our Access databases approach the maximum size of 2 GB. You are correct as magarity, then HTC, provided the solution to meet my goal.
0
 
LVL 13

Expert Comment

by:magarity
ID: 39696458
I recommend people reaching the 2GB limit in Access should seriously consider SQL Server Express which is free from Microsoft, interacts well with Access, and has a 10GB limit.
0
 
LVL 21
ID: 39696489
@magarity,

You posted a link to a "competing" site and that violates the rules of EE. Don't be surprised if the link is deleted.
0
 
LVL 21
ID: 39696499
cwood-wm-com,


TheHighTechCoach: Sorry but magarity beat you to the solution.
Yup. It took me longer because I WAS follow the EE rules  of not posting a link to a competing site.
0
 
LVL 13

Expert Comment

by:magarity
ID: 39696604
Utteraccess is a specialty forum for ms access, not much of a direct competitor to a general site like EE.
0
 
LVL 21
ID: 39696869
In EE's  view it is direct competition for the Access section.  I have had links deleted.

I got the message about a previous post I made:


Links to competing Q&A web sites are discouraged. They are subject to deletion unless accompanied by a substantial body of discussion in the EE post.

See this writeup in a recent newsletter for more information:

http://www.ee-stuff.com/Newsletter-old/091113newsletter.htm#tipsfrom

SouthMod
EE Moderator
SouthMod@e-e.com
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

688 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