Objective:
The Error:
Dataset not in Insert or Edit Mode appears the second time of calling this function
TDBEditBox1.SetFocus;
Form_Search:= TForm_Search.Create(Application);
with Form_Search do
Begin
showmodal;
//Get Result from Database
if trim(TempResult) <> '' then
Begin
TDBEditBox1.Field.Value := MResult;
End;
End;
The setup includes:
Please assist
The error is coming because of the following line: TDBEditBox1.Field.Value := MResult; at this line your dataset is not in Insert or Edit mode. You can add following check to avoid this error:
if not (TDBEditBox1.DataSource.DataSet.State in [dsEdit, dsInsert]) then
begin
TDBEditBox1.DataSource.DataSet.Edit;
// Or TDBEditBox1. DataSource.DataSet.Insert; depending on the operation you are doing (Edit or Insert)
end;
TDBEditBox1.Field.Value := MResult;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With