ADO UpdateBatch Method

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

ADO UpdateBatch Method

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.

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 the save operation fails, a run-time error occurs and the errors are stored in the Errors collection.

Tip: The CancelBatch method cancels all batch updates.

Note: Not all Recordset objects supports batch updating.

Syntax

bool=objRecordset.UpdateBatch affectrecords

Example

If MsgBox("Batch Save All Changes", vbYesNo) = vbYes Then
    objRecordset.UpdateBatch
    MsgBox "All Changes Updated"
 Else
    objRecordset.CancelBatch
    MsgBox "All Changes Cancelled"
 End If


There is one optional parameter.

Parameter

Description

affectrecords Optional. An AffectEnum value that specifies which records this method will affect.

Note: The value adAffectGroup will generate an error if there are no visible records in the Recordset

AffectEnum Values

Constant Value

Description

adAffectCurrent 1 Affects only the current record
adAffectGroup 2 Affects only records that satisfy the Filter setting (Filter must be set to a FilterGroupEnum value or an array of Bookmarks)
adAffectAll 3 Affects all records if there is no Filter. Affects only visible records in the current chapter if Filter is set to a string criteria. Affect all rows of the Recordset if Filter is set to a FilterGroupEnum value or an array of Bookmarks
adAffectAllChapters 4 Affects all records in all child Recordset, including those hidden by a currently applied filter