ADO Fields Collection

Home | About me | EXCEL VB Programming (XL97-2003) | ACCESS Programming | EXCEL VB.Net Programming | EXCEL Spreadsheet Functions Material Management  |  Guestbook
 

ADO Fields Collection

Version: 2.5
The Fields Collection has a wider selection of methods than the various other collections in ADO. For example, the Append method allows you to add Field objects to the collection and the Update and CancelUpdate methods give you control over updates.

If you reference by name a Field object that does not exist, a new Field object with that name will be appended automatically to the Fields Collection. The Status property for this newly appended Field will be assigned a FieldStatusEnum value of adFieldPendingInsert. Further, if allowed by your provider, the Field will be created in the data source the next time you call the Update method.

There are two special fields which can be referenced in a Record object by using the FieldEnum constants.

FieldEnum Constants

Constant Value

Description

adDefaultStream -1 References the field containing the default stream
adRecordURL -2 References the field containing the absolute URL

A Recordset object can also have a Fields Collection.

The Fields Collection has two properties and six methods.


Properties
Count
The Count property returns a long value that is the number of items in the collection.

Methods
Append

Syntax: 
 Fields.Append Name, Type, DefineSize, Attrib, FieldValue

The Append method is used to add (append) a Field object to the Fields Collection.

CancelUpdate
The CancelUpdate method cancels all pending deletions, insertions, or updates to the Fields Collection for a specific Record object.
 
Delete

Syntax:  
Fields.Delete Index
 
The Delete method designates that a specified Field object is to be deleted from the Fields Collection.
 
Refresh
Although, the Refresh method is used to update objects in a collection, this method has no effect on the Fields Collection of the Record object.
 
Resync
The Resync method is used to refetch the data from the underlying data source and to update (resynchronize) the values in the OriginalValue, UnderlyingValue, and Value properties of Field objects that are in the Fields Collection object of a Record object, or just to update the UnderlyingValue property.
Update
The Update method is called to make additions, deletions, and updates to the Fields Collection of the Record object.