Delete Method (Fields Collection)

The Delete method removes all user-defined and optional Field objects from the Fields collection.

Syntax

objFieldsColl.Delete( )

Remarks

The Delete method operates only on user-defined fields and on fields considered optional by the underlying provider.

The Delete method performs an irreversible operation on the collection. It calls Release on the collection's reference to every Field object. If you have another reference to a field, you can still access its properties and methods, but you can never again associate it with any collection because the Add method always creates a new object. You should Set your reference variable either to Nothing or to another field.

The final Release on each Field object takes place when you assign your reference variable to Nothing, or when you call Delete if you had no other reference. At this point the object is removed from memory. Attempted access to a released object results in an error return of CdoE_INVALID_OBJECT.

Be cautious using the Delete method with a collection, because it deletes all the collection's member objects. To delete only one Field object, use the Delete method specific to that object.

The effect of the Delete method is not permanent until you use the Update method on the parent object containing the Fields collection, or the Send or Delete method if the parent is a Message object. A permanently deleted member cannot be recovered. However, the collection itself is still valid, and you can Add new members to it.