Print Number of Reocrds in a Table using VBA

  • Thread starter Thread starter don
  • Start date Start date
D

don

I am ashamed to say that I forgot to bookmark the web page
that showed me this....

I need a simple print out that shows the number of records
in every table in an mdb file. From what I can recall,
the result printed two simple columns.... it printed the
table name, and then the number of records.

It ran a While... Do Loop I believe while building a
string.

At the end it had a Debug.Print line and then I just
copied the results from the immediate window into notepad
or someting.

I recall it being 10 lines of code or so.

Is anyone able to assist? Thank you so much in advance.

Don
 
Assuming you've got a reference set to DAO, the following will work:

Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim strOutput As As String

Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
If (tdfCurr.Attributes And dbSystemObject) = 0 Then
strOutput = tdfCurr.Name & ": " & DCount("*", tdfCurr.Name) & vbCrLf
End If
Next tdfCurr

Debug.Print tdfCurr
 
Back
Top