The error occurs because of the following line: TDBEditBox1.Field.Value: = MResult; on this line, your data set is not in Insert or Edit mode. You can add the 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;
source share