By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,338 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

Delete sql confirm

stephane
P: 35
how to cancel default and make own confirm message showing during when execute delete sql query?

ive got such code
Expand|Select|Wrap|Line Numbers
  1.     SQL1 = "DELETE FROM Clients WHERE contact=" & [contact]
  2.     SQL2 = "DELETE FROM Contacts WHERE id=" & [contact]
  3.  
  4.     DoCmd.RunSQL SQL1
  5.     DoCmd.RunSQL SQL2
  6.  
so user must confirm delete two times
Feb 13 '07 #1
Share this Question
Share on Google+
2 Replies


ADezii
Expert 5K+
P: 8,638
how to cancel default and make own confirm message showing during when execute delete sql query?

ive got such code
Expand|Select|Wrap|Line Numbers
  1.     SQL1 = "DELETE FROM Clients WHERE contact=" & [contact]
  2.     SQL2 = "DELETE FROM Contacts WHERE id=" & [contact]
  3.  
  4.     DoCmd.RunSQL SQL1
  5.     DoCmd.RunSQL SQL2
  6.  
so user must confirm delete two times
Here is 1/2 of the puzzle - let me know if you need help with the other 1/2:
Expand|Select|Wrap|Line Numbers
  1. Dim MySQL As String, Msg As String, Response As Integer
  2. Msg = "Delete ALL Records from YourTableName"
  3.  
  4. Response = MsgBox(Msg, vbQuestion + vbYesNo + vbDefaultButton1, "Deletion Prompt")
  5. If Response = vbYes Then
  6.    'Turn OFF Delete Notification
  7.    DoCmd.SetWarnings False
  8.  
  9.    MySQL = "DELETE * FROM YourTableName;"
  10.    DoCmd.RunSQL MySQL
  11.  
  12.    'Custom Confirmation
  13.    MsgBox "All Records have been DELETED from tblYourTableName", vbExclamation, "Delete Confirmation"
  14.  
  15.    'Turn ON the display of System Messages
  16.    DoCmd.SetWarnings True
  17. Else    'User changed his/her mind
  18. End If
Feb 13 '07 #2

stephane
P: 35
thenks)
no more questions)
Feb 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.