How do I access record values in DatasetProvider.BeforeUpdateRecord?

All updates made to a ClientDataset are placed in ClientDataset.Delta. The Delta property
is passed around throughout the course of the MIDAS reconciliation. To see exactly what this
property looks like, you can use the following code:
  ClientDataset2.Data := ClientDataset1.Delta;

Notice that there is one row for inserts and deletes, and two rows for modifications.
The original row is first, followed by the changed fields in the second row. If you
were to inspect the new ClientDataset.UpdateStatus for these rows, you would find
that they are usUnmodified and usModified, respectively. Fortunately, there is an easy
way to determine which fields have changed without resorting to Next and Previous calls.

In the BeforeUpdateRecord event, you can see if a field has changed by using the
following code:
if not VarIsEmpty(DeltaDS.FieldByName('FieldName').NewValue) then
  FieldHasChanged;

To see if the field has been explicitly set to NULL, use the following code:
if VarIsNull(DeltaDS.FieldByName('FieldName').NewValue) then
  FieldHasBeenSetToNull;

The BeforeUpdateRecord event is also a great place for validating business rules on
the server. If you want to enforce a certain rule, you can use the NewValue, CurValue,
and OldValue properties of the TField returned by DeltaDS.FieldByName('FieldName').
To force a 10% increase to a field anytime it is modified, use the following code:
if UpdateStatus = usModify then
  DeltaDS.FieldByName('FieldName').NewValue := DeltaDS.FieldByName('FieldName').OldValue * 1.1;

Notice that there is no Edit or Post in the above code. Setting NewValue is sufficient to
get the change written to the database.

Note: NEVER use the AsXXX properties of the TField. The values from these
properties make no sense in this context.

Lastly, when writing code in the BeforeUpdateRecord event, it is important to
remember that you should not traverse through the DeltaDS dataset. If you do,
you will confuse MIDAS.