I do have a possible solution for you.
In stead of using the BeforeEdit and doing an Abort you can use the AfterEdit and do a Cancel on the Dataset.
This worked for me in my adjusted sample program:
procedure TForm1.Dt1AfterEdit(DataSet: TDataSet);
begin
if DataIsLock then
Datsaet.Cancel;
end;
BTW. It's also really confusing that you switch the dataset of ActDS datasource when switching the Groupbox.
Just add the same eventhandler to Dt1.AfterEdit to Dt2.AfterEdit.
They can point to the same eventhandler and you can use "Dataset" to do your handlings on.
Thank for your help.
When DataIsLock, I don't wan't users to edit/insert or delete record.
With your method, I pointed All Dataset.AfterEdit & Dataset.AfterInsert to the same event handler, this worked OK, except for delete record.
Although AfterDelete or BeforeDelete pointed to the same handler in AfterEdit event, record still deleted.
So for delete event, I adjusted the code into like these, this is also answering your question about the use of switching ActDs.Dataset (in my app, users must put mouse location in TDBEdit/TDBGrid to choose which record will be deleted)
procedure TForm1.btnDelClick(Sender: TObject);
begin
if (DataIsLock) and (ActDS.DataSet =Dt2) then exit;
if ActDS.DataSet =Dt1 then Dt1.Delete
else Dt2.Delete;
end;
I think, this is the best solution for now, thanks again.
So, if this a bug in TDBEdit, I will change Thread's Title so others will be aware of this bug in Linux.