Submitted By: Umesh Chandra Thakur

Lists all the tables (both system- and user-created) in an Access database.

Visual Basic
Edit|Remove
'--------------------------------------------------
'List all tables in a MS-ACCESS Database(MDB) file
'Author: Umesh C. Thakur (ucthakur@hotmail.com)
'--------------------------------------------------

strDBPath="C:\Documents and Settings\gstemp\Desktop\Stuff\Script Database\ready-to-publish.mdb"

Set objConn = CreateObject("ADODB.Connection")

on error resume next
objConn.Open "Provider= Microsoft.Jet.OLEDB.4.0; " & "Data Source=" & strDBPath

if err.number <> 0 then
	wscript.echo "ERROR connecting to database: " & err.number & ":" & err.Description
	wscript.quit(-1)
end if

wscript.echo "Listing tables from database:" & strDBPath

set objDBCatalog=CreateObject("ADOX.Catalog")
set objDBCatalog.activeConnection=objConn

wscript.echo "TABLE NAME" & vbTab & "TABLE TYPE"
For Each objTable In objDBCatalog.Tables  ' Loop through tables
      wscript.echo objTable.Name & vbTab & objTable.type 
next