As regards Form2.Close, I've tried Self.Close and Close but the same happens. The record will not get deleted.
No, it's not your actual problem but you should use
ModalResult := mrOk;
Or
ModalResult := mrCancel;
Instead of Form2.Close.
You can even use the result of ShowModal ( it's a function) instead of candelete.
This is better code.
if Form2.ShowModal = mrOk then
begin
SQLQuery1.Delete;
SQLQuery1.ApplyUpdates;
SQLTransaction1.Commit;
end;
and
procedure TForm2.btnYesClick(Sender: TObject);
begin
ModalResult := mrOk;
end;
procedure TForm2.btnNoClick(Sender: TObject);
begin
ModalResult := mrCancel;
end;
No need for candelete.
But as stated, your problem still remains.
There is probably something wrong with the deletesql statement.
(Or something else, but we can't see that without more code)