Examples Delphi

If you want to keep a dataset in dsInsert/dsEdit mode after a validation fails, but do not want to loose your input, use Abort in the BeforePost() event.
(If you would use Dataset.Cancel, you'd loose the input and return to browse mode.)

procedure TForm1.Table1BeforePost(DataSet: TDataSet);
begin
if Table1ID.Value <= 0 then
begin
// the data is invalid!!
Showmessage('Error! Invalid value!');
Abort
end
else
Table1.Post;
end;