Public Function FieldNames(dbPath As String, TableName As _
String) As Collection
  \'dbPath: Full Path to an Access Database
  \'TableName: Name of a Table within the
\'Returns: Collection of the names
\'of fields in that table
\'or Nothing if there is an error
\'Requires: a reference to data access
\'objects (DAO) in your project

Dim oCol As Collection
Dim db As DAO.Database
Dim oTD As DAO.TableDef
Dim lCount As Long, lCtr As Long
Dim f As DAO.Field
On Error GoTo errorhandler
Set db = workspaces(0).opendatabase(dbPath)
Set oTD = db.TableDefs(TableName)
Set oCol = New Collection
With oTD
    lCount = .Fields.Count
      For lCtr = 0 To lCount - 1
        oCol.Add .Fields(lCtr).Name
End With
    Set FieldNames = oCol
Exit Function
    On Error Resume Next
    If Not db Is Nothing Then db.Close
    Set FieldNames = Nothing
    Exit Function
End Function