Retrieve Field Names from Recordset (1 Viewer)

Emohawk

What a wicked mullet...
Local time
Today, 11:41
Joined
Mar 14, 2002
Messages
79
I'm writing a method that takes info from a Table and exports it to a Excel spreadsheet.

Is it possible to capture the names of each field individually so I can setup the column names of the spreadsheet?

Ta.
 

RichMorrison

Registered User.
Local time
Today, 05:41
Joined
Apr 24, 2002
Messages
588
Yes.

You can use the "Name" property of the "Fields" collection of a "Recordset".

I don't remeber the exact syntax, but it' something like:

Dim rs As Recordset, intFieldNum As Integer

' open the recordset somehow

For intFieldNum = 0 to (rs.Fields.Count - 1) ' it is zero-based
strFieldName = rs.Fields(intFieldNum).Name
Next intFieldNum

Access help will provide a correct sample.

RichM
 

Users who are viewing this thread

Top Bottom