Topic: Delete Message

Hi folks,
Here's what I would like to do.
When a user clicks on my Delete User button, I would like to display an extra Warning message.
-
Something like: ShowMessage('WARNING - This will DELETE this user and all of the records for this user.  Choose Yes or No on the next message');
-
Then I would like the normal message for the DELETE button to come up so they can choose whether to continue or not.
-
I've tried putting my message on some of the different EVENTS for the Delete button.
However when I do that it seems to prevent the normal Delete warning message from appearing.
-
It doesn't seem to me that this should be too hard, but I must be missing something.
-
Your thoughts will be appreciated.
Thanks, Frank

Re: Delete Message

Would this help?

Ignore the SQL, you don't need to do that, the trick is in using MessageDlg function which has both button options and a message capability.

procedure frmEditOrderQty_btnFrmAmendDeleteRecord_OnClick (Sender: TObject; var Cancel: boolean);
 var
 text : string;
 btn :integer;
begin

  
   text := 'ORDER ITEM '+#13#13 + frmEditOrderQty.edtfrmAmendDescription.Text +'  x '+ frmEditOrderQty.edtNewQty.Text;

   btn := messageDlg('CONFIRM DELETION OF '+text,mtWarning, mbCancel+mbOK, 0);

   if  btn  = mrCancel then
      Exit
   else
     begin
       SQLExecute('DELETE FROM orders WHERE orders.id =  "'+ intToStr(frmMain.tgOrders.dbItemID) +'"');
       ShowMessage(#13#13 + text + ' has been DELETED' );
       frmMain.tgOrders.dbupdate
      end;

 // frmEditOrderQty.Enabled := True;

  frmEditOrderQty.Close;

end;

For other MessageDlg options see http://www.delphibasics.co.uk/RTL.asp?Name=messagedlg

On a clear disk you can seek forever

3 (edited by papafrankc 2020-11-11 07:13:18)

Re: Delete Message

CDB many thanks it works great.
-
I just used the code from 'btn' to 'Exit', changed the message to what I wanted & it worked perfectly.
-
FYI, In my application a User can have lots of data in a whole bunch of forms.  So I want to make sure that they REALLY REALLY want to delete the user.
-
I know the message from the Delete button should be enough to warn them but I'm just being extra cautious.
-
I looked up that MessageDlg function and it looks like a really useful function.
-
Thanks again, Frank