Delete Method

The Delete method on a Recordset object deletes the current record or a group of records.

recordSet.Delete
 

Parameters

AffectedRecords
This optional parameter specifies an AffectEnum value that determines how many records the Delete method will affect. The AffectEnum value can be one of the following constants:
Enumeration Value Description
adAffectCurrent 1 This value deletes only the current record.
adAffectGroup 2 This value deletes the records that satisfy the current Filterproperty setting. You must set the Filter property to one of the valid predefined constants to use this option.

Remarks

The Delete method is used to mark the current record or a group of records in a Recordset object for deletion. If the Recordset object does not allow record deletion, an error occurs. If you are in immediate update mode, deletions occur in the database immediately. Otherwise, the records are marked for deletion from the cache and the actual deletion happens when the UpdateBatch method is called. (Use the Filter property to view the deleted records.)

Retrieving field values from the deleted record generates an error. After deleting the current record, the deleted record remains current until you move to a different record. After you move away from the deleted record, it is no longer accessible.

If you are in batch update mode, the CancelBatch method can be used to cancel a pending deletion or group of pending deletions.

If the attempt to delete records fails because of a conflict with the underlying data (for example, a record has already been deleted by another user), the data provider returns warnings to the Errors collection but does not halt program execution. A run-time error occurs only if there are conflicts on all the requested records.