Could anyone please tell me, whether it is possible to return the field names of an Access2000 database when their are no records in the table? many thanks.
Sub lstfieldNames(ByVal tblName As String)
'Returns names of fields in table tblName in current db
Dim db As DAO.Database
Dim fld As DAO.field
Set db = CurrentDb()
For Each fld In db.TableDefs(tblName).Fields
Debug.Print fld.Name
Next
End Sub
Store the results of this query in a recordset and you can loop through the fields to get their name. The good part is that this also works when there ARE records in the table - it will return an empty recordset with only the field names.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.