00

Recommended Answers

All 2 Replies

Enumerate field names in a recordset

Function getfieldnames(mytable As String)

Dim fld As Field
Dim dbf As Database
Dim rs As Recordset
Dim sql As String

Set dbf = CurrentDb()
Set rs = dbf.OpenRecordset(mytable, dbOpenDynaset, dbSeeChanges)
sql = ""


For Each fld In rs.Fields
sql = sql & fld.Name & ","
Next
getfieldnames = Left(sql, Len(sql) - 1)
dbf.Close
rs.Close


End Function

i tried below code and its working as i wanted

recordset.Fields(1).Name retrives the field name


thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.