Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to list ms access 2007 tables, queries, etc. (objects) using vbscr

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
0
0
US
Hi.
i have several ms access 2007 databases currently used by many users. i like to have a vbs to list all the object in each database. i had an old script that listed objects from access 97. but, it's not working on access 2007. i modified it to access the sys objects, but it says no permission to read the sys objects.
any ideas?
thanks much.
here's the code:
Code:
db_path = "C:\Documents and Settings\a032299\Desktop\AMORTIZE.MDB"  
db_file = db_path 
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet  = CreateObject("ADODB.Recordset")
objConnection.Open _
   "Provider = Microsoft.Jet.OLEDB.4.0; " & _
   "Data Source = " & db_path 
commandstring = "SELECT MSysObjects.Name FROM MsysObjects WHERE " & _ 
      "(MSysObjects.Type)=1;"
objRecordSet.Open commandstring, objConnection  
if not objRecordSet.EOF then 
   objRecordSet.MoveFirst 
   Do Until objRecordSet.EOF
      tbl_name = objRecordset.Fields.Item("name")
        
      objRecordSet.MoveNext
       
      msg = msg & tbl_name & vbcrlf
       
   Loop
end if 

msgbox msg
 
objRecordSet.Close
 
Did the problem just start after an upgrade from Access 97 to 2007? What else (if anything) has changed on the system?

Is the OS 32 bit or 64 bit?
 
the os is 32 bit (xp-sp3).
the problem started when they took away access 97 and installed access 2007. and besides, it's not the point. i'm looking for listing sys objects in access 2007. that's what my original post was.
thanks.
 
I'd use an ADOX.Catalog object instead of trying to read an hidden undocumented system table.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks PHV.
i'm not familiar with the syntax for ADOX.Catalog object.
any ideas?
thanks.
 
i tried this:
and it get this error msg on line 9
Object required: ADOX
Code:
db_path = "C:\Documents and Settings\a032299\Desktop\AMORTIZE.MDB"  
db_file = db_path 
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet  = CreateObject("ADODB.Recordset")
objConnection.Open("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\Documents and Settings\a032299\Desktop\AMORTIZE.MDB")
   set Catalog = ADOX.Catalog
   set table = ADOX.Table
   Set Catalog = New ADOX.Catalog
   Set Catalog.ActiveConnection = objConnection 
   'List tables And columns
  set Table = NEW ADOX.Table 
  For Each Table In Catalog.Tables     
      msg = msg & Table.Name & vbcrlf 
  Next
msgbox msg
line 9 is: set Catalog = ADOX.Catalog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top