04 UpdateFrom - AndrewMB2/Logic-Architect-for-Excel-VBA GitHub Wiki

UpdateFrom method

Updates a RsetData object from another Xdata object. Returns True if successful, otherwise False.

Applies to

TableData ArrData RsetData Xdata XShared

Parameters

Name Type Description
Xd Xdata The Xdata object from which the data will be updated.
KeySet Value, array or ParamArray Keys for the database table. In necessary these cane be obtained using the GetKeys method. If there is a single autonumber key (which must be the first field in the recordset) enter 0.

UpdateFrom updates a RsetData object from another Xdata object. Changed records are updated, removed records are deleted, new records are added and unchanged records remain unchanged.

The Xd object being used should contain the same fields as the RsetData object being updated, and the two datasets should be comparable - attempting to update the result of a different query would produce incorrect results.

UpdateFrom can be used in a multiuser environment, though:

  • The recordset should not be requeried before updating, doing so would result in the loss of any updates done by other users.
  • If the cursor is static, then any updates to records by other users since the original query was run will not be affected.
  • If the cursor is keyset, then any updates to records or deletes by other users since the original query was run will be reversed.

For this reason a static cursor (which requires a local cursor) is usually the most appropriate.

Where the key is an autonumber field (which must be the first field in the recordset) then any records added by UpdateFrom will acquire new numbers set by the autonumber algorithm.