Return to Snippet

Revision: 61166
at December 1, 2012 07:41 by angelia


Initial Code
' create the list of tables and queries using the Database Object and its QueryDef and TableDef collections
'http://www.techrepublic.com/article/how-to-create-a-list-of-tables-or-queries-from-access/5047664
Public Sub GetMyObjectsList()
    Open "c:\Tables and Queries.txt" For Output As #1
    Dim db As Database
    Dim Qry As QueryDef
    Dim QryNames As String
    Dim QryCount As Integer
    Dim Tbl As TableDef
    Dim TblNames As String
    Dim TblCount As Integer
    Set db = CurrentDb
    QryCount = 0
    TblCount = 0
    For Each Qry In db.QueryDefs
        QryNames = QryNames & Qry.Name & ", "
        QryCount = QryCount + 1
        Print #1, charpos; Qry.Name
    Next
    For Each Tbl In db.TableDefs
     If Tbl.Attributes = 0 Then 'Ignores System Tables
        TblNames = TblNames & Tbl.Name & ", "
        TblCount = TblCount + 1
        Print #1, charpos; Tbl.Name
     End If
    Next
    QryNames = QryNames & "TOTAL Query Count: " & QryCount
    TblNames = TblNames & "TOTAL Table Count: " & TblCount
   ' MsgBox QryNames
   ' MsgBox TblNames
    db.Close
    Set db = Nothing
    Close #1
End Sub

Initial URL


Initial Description
' create the list of tables and queries using the Database Object and its QueryDef and TableDef collections
'http://www.techrepublic.com/article/how-to-create-a-list-of-tables-or-queries-from-access/5047664

Initial Title
list of tables and queries using the Database Object

Initial Tags


Initial Language
Visual Basic