Code:
Public Function FieldNames(dbPath As String, TableName As _
String) As Collection
\'Input:
  \'dbPath: Full Path to an Access Database
  \'TableName: Name of a Table within the
      \'Database
\'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
    Next
End With
    db.Close
    Set FieldNames = oCol
    
Exit Function
errorhandler:
    On Error Resume Next
    If Not db Is Nothing Then db.Close
    Set FieldNames = Nothing
    Exit Function
End Function