leegold58 wrote:
Newbie question must of been asked before but:
How do I count the number of tables in a database?
Without VB, prefer to use SQL or the Access GUI somehow.
Thanks.
Lee g.
Well, you could count them by hand.
Or you could display system objects and run a query on the object type
on MSysObjects.
Here's a couple of VBA routines
Sub CountTables()
MsgBox "There are " & CurrentDb.TableDefs.Count
End Sub
Sub CountTables()
Dim tdf As TableDef
Dim i As Integer
For Each tdf In CurrentDb.TableDefs
If Left(tdf.name, 4) <"MSys" Then i = i + 1
Next
MsgBox "There are " & i & " tables"
End Sub
I got a different count from each routine. Why? In the first
CountTables it included the system tables. In the second one the system
tables were excluded. I have 9 system tables in my version of Access.
So I could have used
MsgBox "There are " & CurrentDb.TableDefs.Count -9
in my first VBA example.