Writes all pending batch updates to the underlying database.
The UpdateBatch method is called to save to the data source all of the
pending changes and additions that have occurred in a Recordset object
since the last update.
Clearly, the Recordset must support batch updating.
When a Recordset is in batch updating mode, all of the changes and new additions
are saved in a local cache until the BatchUpdate method is called.
(The LockType property of the Recordset object must return the
adLockBatchOptimistic constant which specifies that multiple users can modify
the data and that all changes are locally cached.)
If all or part of the UpdateBatch fails, a warning is returned to the
Errors Collection and an error is generated.
You can cancel a BatchUpdate by calling the CancelBatch method.
There is one optional parameter.
AffectEnum Constants
Constant | Value | Description |
---|---|---|
adAffectAll | 3 | Update all records including those hidden by a filter |
adAffectAllChapters | - | Not recognized by this method |
adAffectCurrent | 1 | Update only the current record |
adAffectGroup | 2 | Update only those records that passed through the filter in effect |
If MsgBox("Batch Save All Changes", vbYesNo) = vbYes Then
objRecordset.UpdateBatch
MsgBox "All Changes Updated"
Else
objRecordset.CancelBatch
MsgBox "All Changes Cancelled"
End If