Thompyt, maybe you will find useful the function below:
Code:
Function TableFields(ByVal strTable As String, ByRef varHeaders() As Variant) As Long
Dim i As Integer
On Error Resume Next
With CurrentDb.TableDefs(strTable).OpenRecordset
With .Fields
ReDim varHeaders(.Count, 2)
For i = 0 To .Count - 1
varHeaders(i, 0) = i + 1 'Field's Index
varHeaders(i, 1) = .Item(i).Name 'Field's Name
varHeaders(i, 2) = .Item(i).Properties("Caption") 'Field's Caption
Next i
TableFields = .Count
End With
Best regards,
John
.Close
End With
End Function
It returns the count of the fields of the table with the strTable name and fills the var Headers() array with their names (and captions if exist).
You can use it as follows:
Code:
Sub PrintTableHeaders()
Dim TD As DAO.TableDef
Dim vHeaders() As Variant
Dim i As Integer
For Each TD In CurrentDb.TableDefs
If Not TD.Name Like "MSys*" Then
Debug.Print TD.Name
Debug.Print vbTab & "Details of " & TD.Fields.Count & " Fields"
For i = 0 To TableFields(TD.Name, vHeaders) - 1
Debug.Print vbTab & vHeaders(i, 0) & ". " & vHeaders(i, 1) & " (""" & vHeaders(i, 2) & """)"
Next i
End If
Next TD
End Sub