Finding table field names via code

J

John

Hi

How can I iterate through tables (linked or otherwise) and get the names of
following types of fields via code;

- datetime fields,

- txt(255) fields?

Many Thanks

Regards
 
A

Allen Browne

Here's how to iterate tables:

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 Not (tdf.Name Like "~*" Or tdf.Name Like "MSys*") Then
Debug.Print tdf.Name
End If
Next

Next step is to iterate the Fields of the TableDef, examining the Type of
each one. This example shows how to do that for a table:
http://allenbrowne.com/func-06.html
 
D

Douglas J. Steele

Just curious whether you've noticed any differences using

For each tdf in db.TableDefs
If (tdf.Attributes And dbSystemObject) = 0 Then
Debug.Print tdf.Name
End If
Next

instead of If Not (tdf.Name Like "~*" Or tdf.Name Like "MSys*") Then
 
A

Allen Browne

At current processor speeds, I doubt there's any practical performance
difference, Doug.

There could be a different set of results.
 

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

Top