Skip to main content

ClearFields

procedure ClearFields;

Example

procedure ResetPendingRecord(const Data: TvxClientDataSet);
begin
Data.ClearFields;
Data.FieldByName('Code').AsString := 'A100';
end;

Usage

ClearFields reinitializes every field in the current pending edit or insert record and recalculates calculated fields.

  • Enter Edit, Append or Insert first.
  • Reassign all business-required fields after clearing and validate before Post.
  • The operation affects only the pending buffer and is not persisted until Post.

Additional Technical Info

ClearFields is declared by hidden ancestor TDataSet and is normally used through a visible descendant such as TvxClientDataSet. It clears the current record buffer, not the dataset schema or all records.

Source-backed behaviour

The method requires an edit-mode state; otherwise it raises EDatabaseError (Dataset not in edit or insert mode). It sends a browse-mode data event, frees field buffers, calls descendant InternalInitRecord on the active buffer, recalculates fields except in set-key state, and sends a record-change event.

The result can include descendant defaults/internal values rather than every field being literal Null. The new-record event is not rerun by this method.

Fields exposes the reinitialized values. Cancel restores/abandons the complete edit instead.

Official RTL references

Created 2026-07-15