Hi Paul,
Try these procedures. The first one writes the results to a file named Fields.txt in your default
directory defined in Access. The second one writes a similar file to the same folder that the
database is located in.
Tom
________________________________
Option Compare Database
Option Explicit
Sub EnumerateTablesAndFieldsAndType()
' Code provided by Michael Freeland, 2/4/2004, to DL AccessDevTalk
' Subject = "RE: Enumerating Field Order in Import Spec File in MSysIMEXColumns"
Dim intloop, intloop2 As Integer
Open "Fields.txt" For Output As 1
'
On Error Resume Next
' Print information about TableDefs collection.
Debug.Print CurrentDb.TableDefs.Count & " TableDefs"
Write #1, CurrentDb.TableDefs.Count & " TableDefs"
For intloop = 0 To CurrentDb.TableDefs.Count - 1
Debug.Print "Table " & intloop & " Name =" & CurrentDb.TableDefs(intloop).name
Write #1, "Table " & intloop & " Name =" & CurrentDb.TableDefs(intloop).name
For intloop2 = 0 To CurrentDb.TableDefs(intloop).Fields.Count - 1
Debug.Print "Table " & intloop & " Field " & intloop2 & " Name = " _
& CurrentDb.TableDefs(intloop).Fields(intloop2).name _
& " & Type = " & CurrentDb.TableDefs(intloop).Fields(intloop2).Type
Write #1, "Table " & intloop & " Field " & intloop2 & " Name = " _
& CurrentDb.TableDefs(intloop).Fields(intloop2).name _
& " & Type = " & CurrentDb.TableDefs(intloop).Fields(intloop2).Type
Next intloop2
Next intloop
Close #1
End Sub
Sub EnumerateTablesAndFieldsAndType2()
' Slightly modified version of the above code
Dim intloop, intloop2 As Integer
'Open Fields.txt" in the current folder for Output As 1
Open CurrentProject.Path & "\Fields.txt" For Output As 1
'
On Error Resume Next
' Print information about TableDefs collection.
Debug.Print CurrentDb.TableDefs.Count & " TableDefs"
Write #1, CurrentDb.TableDefs.Count & " TableDefs"
For intloop = 0 To CurrentDb.TableDefs.Count - 1
Debug.Print
Write #1, ""
Debug.Print "Table " & intloop & " Name =" & CurrentDb.TableDefs(intloop).name
Write #1, "Table " & intloop & " Name =" & CurrentDb.TableDefs(intloop).name
For intloop2 = 0 To CurrentDb.TableDefs(intloop).Fields.Count - 1
Debug.Print " Field " & intloop2 & " Name = " _
& CurrentDb.TableDefs(intloop).Fields(intloop2).name _
& " & Type = " & CurrentDb.TableDefs(intloop).Fields(intloop2).Type
Write #1, " Field " & intloop2 & " Name = " _
& CurrentDb.TableDefs(intloop).Fields(intloop2).name _
& " & Type = " & CurrentDb.TableDefs(intloop).Fields(intloop2).Type
Next intloop2
Next intloop
Close #1
End Sub
________________________________
Hi All,
I have a table loaded in Access with only a few records, but many many
different columns. By the time I manage my way to the end of a record,
I've long forgotten any detail from the beginning of the record.
Perhaps "Duhhh" but there are more than 50 fields
It would be really great if I could print the list of fields, like in
the old DOS based data propgrams.
Anybody remember this?
FieldName Type Length
Name Character 25.0
Address Character 20.0
Sales Numeric 10.2
Date Date 8.0
Can I print this sort of list from within Access?
If so... how?
Thanks Much
Paul