/ Published in: Visual Basic
                    
                                        
' 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
                'http://www.techrepublic.com/article/how-to-create-a-list-of-tables-or-queries-from-access/5047664
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
' 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
Comments
 Subscribe to comments
                    Subscribe to comments
                
                