Confirming delete of a record
Posted: Wed 13 Dec 2006 09:30
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
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