Value
property Value: Variant read write;
Example
procedure CopyFieldValue(const Source, Target: TvxClientDataSet; const Name: string);
begin
Target.Edit;
Target.FieldByName(Name).Value := Source.FieldByName(Name).Value;
end;
Usage
Reads or writes the field's generic Variant value, with fields able to redeclare a more specific Value type and Null assignment clearing the field.
- Use typed
As...members when the expected type is known; use Variant state tests when it is not. - Enter edit/insert state before assignment and handle conversion/validation exceptions.
- Never treat a successful assignment or
Postas proof that a database transaction was executed.
Additional Technical Info
On TField, Value is an alias of AsVariant and is the general-purpose field value used extensively by Velox mapping and DataView code.
Source-backed behaviour
The getter invokes the concrete field's GetAsVariant; the base implementation raises. The setter calls SetAsVariant: Variant Null calls Clear, while other values are passed to the descendant SetVarValue and variant conversion failures become field-value database errors. Client-dataset writes require a write state, enforce read-only rules for ordinary fields, invoke OnValidate, verify through DSBase, mutate the active buffer and normally emit a field-change event.
Concrete descendants can redeclare Value with a static type: TBooleanField uses Boolean, TDateTimeField uses TDateTime, and TBlobField uses string. The expression's compile-time field type therefore affects PascalScript typing even when all objects inherit TField. Post commits the client record buffer; persistence to a database is a separate DataView/module operation.