The Fields Collection

The Fields collection contains the values, and information about those values, from the current record in a Recordset object. In Excel, the Fields collection is most commonly used to return the column names of each field in the recordset, prior to accessing the contents of the recordset using the CopyFromRecordset method of the Range object. The following example demonstrates how to read the field names from the Fields collection of a Recordset object:

With Sheet1.Range("A1")

For Each objField In rsData.Fields

.Offset(0, lOffset).Value = objField.Name lOffset = lOffset + 1 Next objField End With

0 0

Post a comment