Author: Tomas Rutkauskas
Keep a dataset in dsInsert/dsEdit mode after validation fails
Answer:
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.)
1 2 procedure TForm1.Table1BeforePost(DataSet: TDataSet);
3 begin4 if Table1ID.Value <= 0 then5 begin6 // the data is invalid!!7 Showmessage('Error! Invalid value!');
8 Abort
9 end10 else11 Table1.Post;
12 end;