Count of the objects in your MS Access Database

Have you ever needed to get a simple count of the number of :

  • Tables
  • Queries
  • Forms
  • Macros
  • Reports
  • Modules

I recently needed to get some summary data regarding a database I was working on.  The following single line VBA commands will get you the count(s) you are after.

'Number of Tables
CurrentDb.TableDefs.Count 'includes system tables
'Number of Queries
CurrentDb.QueryDefs.Count
'Number of Forms
Currentproject.AllForms.Count
'Number of Macros
Currentproject.AllMacros.Count
'Number of Reports
Currentproject.AllReports.Count
'Number of Modules
Currentproject.AllModules.Count 'does not include object modules

Easy as can be!

2 responses on “Count of the objects in your MS Access Database

    1. Daniel Pineault Post author

      Using

      CurrentData.AllQueries.Count

      is fine to use.

      That said, CurrentDb.QueryDefs.Count gives you access to everything, even the system queries (~sq_* queries) where as the CurrentData.AllQueries omits the system one. So it comes down to what you are after, what you are trying to achieve exactly.