Link to home
Create AccountLog in
Avatar of martin05
martin05

asked on

Access iterating through tables and queries

Is there an easy way to iterate through access tables and get a count for every one on my system.
I would like to do it with queries as well
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Sub listsize()
Dim db As Database
Dim tdf As DAO.TableDef
Set db = CurrentDb
For Each tdf In db.TableDefs
If Left(tdf.Name, 4) <> "msys" Then Debug.Print tdf.Name & ":" & DCount("*", tdf.Name)
Next tdf
Set db = Nothing
End Sub

This will do it for tables.

I can't see the point in doing it for queries.
Avatar of martin05
martin05

ASKER

the point in doing it for queries is to do comparisons with a database we have migrated to sql
Sorry - I see what you'r after but that isn't what was in my mind.
There are too many reasons why you can't call a query reliably in code.
Action queries, parameter queries just won't run; queries using form references won't run.


I understand,is there any way of excluding linked tables in the table count one ?
try this query

SELECT Count(MSysObjects.Type) AS CountOfQueries, (SELECT Count(MSysObjects.Type)
FROM MSysObjects
HAVING ((MSysObjects.Name) Not Like "msys*") AND (MSysObjects.Type)=1) AS CountOfTables
FROM MSysObjects
HAVING ((MSysObjects.Name) Not Like "~*") AND ((MSysObjects.Type)=5);
ASKER CERTIFIED SOLUTION
Avatar of peter57r
peter57r
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
thanx folks