looking for example

  • Thread starter Thread starter djc
  • Start date Start date
D

djc

looking for example or template code to enumerate all tables and their
fields for an access mdb file? I know it can be done but I have to become
familiar with the table/field structure of a database very quickly and not
having done this before I know it would take me some time to create the
tool. I'm sure someone here already has this kind of thing ready to roll.

anyone?
 
This is very simple example, how to enumerate tables and
fields. All names of fields and tables are saved to
table "EnumTable".

Sub EnumTables()
Dim tbf As TableDef
Dim fld As Field
Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("EnumTable")
With rst
For Each tbf In CurrentDb.TableDefs
If Not tbf.Name Like "MSys*" Then
For Each fld In tbf.Fields
.AddNew
.Fields(0) = tbf.Name
.Fields(1) = fld.Name
.Update
Next fld
End If
Next tbf
.Close
End With
Set rst = Nothing
End Sub
 
worked like a charm... Thank you!

losmac said:
This is very simple example, how to enumerate tables and
fields. All names of fields and tables are saved to
table "EnumTable".

Sub EnumTables()
Dim tbf As TableDef
Dim fld As Field
Dim rst As Recordset

Set rst = CurrentDb.OpenRecordset("EnumTable")
With rst
For Each tbf In CurrentDb.TableDefs
If Not tbf.Name Like "MSys*" Then
For Each fld In tbf.Fields
.AddNew
.Fields(0) = tbf.Name
.Fields(1) = fld.Name
.Update
Next fld
End If
Next tbf
.Close
End With
Set rst = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top