Is there a way to get the schema of the database tables using VB?

  • Thread starter Thread starter joan
  • Start date Start date
J

joan

Hi all,

Hey..newbie here....

Is there a way to read in the schema of access tables using
Vb-script in ACCESS?
 
Hi all,

Hey..newbie here....

Is there a way to read in the schema of access tables using
Vb-script in ACCESS?

VBScript, or VBA? You can use DAO objects and their methods to get at
table and field properties. You'd be using Database, TableDef, Field,
Index, and Property objects.
 
Do you mean something like the following:

Public Sub TableStructures()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim fld As DAO.Field
Set db = CurrentDb()

For Each tdf In db.TableDefs
If UCase$(Left$(tdf.Name, 4)) = "MSYS" Then
' This is a system table, ignore it.
Else
Debug.Print "----------"
Debug.Print tdf.Name
For Each fld In tdf.Fields
Debug.Print fld.Name
Debug.Print fld.AllowZeroLength
Debug.Print fld.Type
Debug.Print fld.Size
' and whatever else you want...
Next fld
End If
Next tdf
End Sub
 
Back
Top