How can I abort deletion of record based on decisions after dbnavigator delete button pressed?
Asked Answered
A

3

7

Can I abort deletion of record based on decisions after dbnavigator delete button pressed? I checked beforeAction Event

if Button = nbDelete then  
  //check if not OK then

Button := nbCancel;

but it doesn't work. Any Help?

I'm using DelPhi XE2, anyDac Components

Amand answered 13/1, 2013 at 7:51 Comment(0)
T
3

Use the BeforeAction event

procedure TForm1.DBNavigator1BeforeAction(Sender: TObject; Button: TNavigateBtn);
begin
  if Button = nbDelete then
  begin
    if MessageDlg('Confirm delete now?', mtConfirmation, [mbYes,mbNo], 0) = mrNo then
    begin
      Abort;
    end;
  end;
end;
Tricycle answered 13/1, 2013 at 20:43 Comment(0)
S
2

You can use the BeforeDelete event:

procedure Tdm.MyDataSetBeforeDelete(DataSet: TDataSet);
begin
  if SomeCondition then
  begin
    ShowMessage('Sorry, you can not delete this record.');
    Abort;
  end;
end;
Sharenshargel answered 2/7, 2015 at 8:12 Comment(0)
H
0

Select the DBNavigator, then on the Object Inspector inside the Options set the noConfirmDelete to "false"

Hoist answered 12/11, 2015 at 19:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.