Finding table field names via code

  • Thread starter Thread starter John
  • Start date Start date
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
 
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
 
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
 
At current processor speeds, I doubt there's any practical performance
difference, Doug.

There could be a different set of results.
 
Back
Top