2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by PM312
0

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

0

i tried below code and its working as i wanted

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


thanks

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.