The CancelBatch method on a Recordset object cancels a pending batch update.
- This optional parameter specifies an AffectEnum value that determines how many records the CancelBatch method will affect.
The AffectEnum value can be one of the following constants:
Enumeration Value Description adAffectCurrent 1 This value cancels pending updates only for the current record. adAffectGroup 2 This value cancels pending updates for records that satisfy the current Filter property setting. You must set the Filter property to one of the valid predefined constants to use this option. adAffectAll 3 This value cancels pending updates for all the records in the Recordset object, including any hidden by the current Filter property setting. This value is the default.
The CancelBatch method is used to cancel any pending updates in a Recordset object in batch update mode. If the Recordset object is in immediate update mode, calling CancelBatch without adAffectCurrent generates an error.
If you are editing the current record or are adding a new record when CancelBatch is called, ADO first calls the CancelUpdate method to cancel any cached changes, and then all pending changes in the recordset are canceled.
It is possible that the current record will be indeterminable after a CancelBatch call, especially if you were in the process of adding a new record. For this reason, it is prudent to set the current record position to a known location in the recordset after the CancelBatch method is called. For example, call the MoveFirst method.
If the attempt to cancel the pending updates fails because of a conflict with the underlying data (for example, a record has been deleted by another user), the 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. The Filter property (adFilterAffectedRecords) and the Status property can be used to locate records with conflicts.