CodeItBetter Programming Another VB Programming Blog

How to list all the objects in a Database using DAO.

Posted on July 3, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'Database - How to list all the objects in a Database using DAO.
Sub ListTopLevelObjects(strPath As String)
    ' This procedure lists the top-level objects in a database.
    '
    ' Arguments:
    '   strPath: The path to the database.

    Dim dbs As Database
    Dim tdf As TableDef, qry As QueryDef
    Dim rel As Relation, ctr As Container
 
    Set dbs = OpenDatabase(strPath)
 
    Debug.Print "Tables: "
    For Each tdf In dbs.TableDefs
        Debug.Print tdf.Name
    Next tdf
 
    Debug.Print "Querys: "
    For Each qry In dbs.QueryDefs
        Debug.Print qry.Name
    Next qry
 
    Debug.Print "Relations: "
    For Each rel In dbs.Relations
        Debug.Print rel.Name
    Next rel
 
    Debug.Print "Containers: "
    For Each ctr In dbs.Containers
        Debug.Print ctr.Name
    Next ctr
    dbs.Close
    Set dbs = Nothing
End Sub
Filed under: Database Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.