Hi,
I have a dbnavigator on my form and I want to display a nicer confirmation window when deleting a record, or infact I want to offer a third alternative. Right now when you press the delete button a message pops up which says "Delete Record" Yes or No.
I want to option to cancel the delete but I can't seem to stop it. The delphi docs mention the abort procedure for tdataset, but the MyDac stuff doesn't have it. It does have Cancel which says it will stop updates.
My code is as follows;
if button=nbdelete then
begin
case messagedlg('Deleting a record removes it from the database.'+#13+#10+
'A deleted record is not available for historical records.'+#13+#10+#13+#10+
'Would you prefer to mark this company as "Inactive"?',mtconfirmation,[mbyes,mbno,mbcancel],0)
of
mryes:begin
contractortable.cancel;
contractortable.edit;
contractortable.FieldByName('CurrentStatus').AsString:='Inactive';
contractortable.Post;
end;
mrcancel:contractortable.cancel;
end;
end;
How can I stop the delete without using the built in confirmation. I have put this code into the beforedelete event and on the buttonclick event. But, the delete still goes ahead.
Craig
Confirming delete of a record
-
captainrproton
- Posts: 7
- Joined: Tue 28 Nov 2006 18:49
- Location: Narooma NSW Australia
Try to move this code to BeforeDelete event handler. And replace the line:
with the following one:
To prevent popping up the dialog box with the "Delete record?" message you should set the ConfirmDelete property of your TDBNavigator object to False.
Code: Select all
mrcancel:contractortable.cancel; Code: Select all
mrCancel: Abort; -
captainrproton
- Posts: 7
- Joined: Tue 28 Nov 2006 18:49
- Location: Narooma NSW Australia