Delete sql confirm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stephane
    New Member
    • Feb 2007
    • 35

    Delete sql confirm

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

    ive got such code
    Code:
        SQL1 = "DELETE FROM Clients WHERE contact=" & [contact]
        SQL2 = "DELETE FROM Contacts WHERE id=" & [contact]
        
        DoCmd.RunSQL SQL1
        DoCmd.RunSQL SQL2
    so user must confirm delete two times
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by stephane
    how to cancel default and make own confirm message showing during when execute delete sql query?

    ive got such code
    Code:
        SQL1 = "DELETE FROM Clients WHERE contact=" & [contact]
        SQL2 = "DELETE FROM Contacts WHERE id=" & [contact]
        
        DoCmd.RunSQL SQL1
        DoCmd.RunSQL SQL2
    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:
    Code:
    Dim MySQL As String, Msg As String, Response As Integer
    Msg = "Delete ALL Records from YourTableName"
    
    Response = MsgBox(Msg, vbQuestion + vbYesNo + vbDefaultButton1, "Deletion Prompt")
    If Response = vbYes Then
       'Turn OFF Delete Notification
       DoCmd.SetWarnings False
    
       MySQL = "DELETE * FROM YourTableName;"
       DoCmd.RunSQL MySQL
    
       'Custom Confirmation
       MsgBox "All Records have been DELETED from tblYourTableName", vbExclamation, "Delete Confirmation"
    
       'Turn ON the display of System Messages
       DoCmd.SetWarnings True
    Else    'User changed his/her mind
    End If

    Comment

    • stephane
      New Member
      • Feb 2007
      • 35

      #3
      thenks)
      no more questions)

      Comment

      Working...