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

5.9k views Asked by At

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

3

There are 3 answers

0
dataol On BEST ANSWER

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;
0
mjn On

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;
0
azios On

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