Results 1 to 5 of 5
  1. #1
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33

    delete confirm dialog when deleting with SQL or recordset

    Hi

    I want the delete confirm dialog to appear when the user wants to delete a record.
    This is the code I thought would work, but it doesn't:

    Code:
    Public aktWert as String
    'all other variables are controls
    
    Private Sub cmdIO()
        DoCmd.SetWarnings True
        Set rsTab = CurrentDb.OpenRecordset("INT03-Team", dbOpenDynaset)
        rsTab.FindFirst "Kürzel = '" & Me.KürzelAuswahl & "'"
        aktWert = Me.KürzelAuswahl
    rsTab.Delete
        rsTab.Close
        Set rsTab = Nothing
    End Sub
    
    Private Sub Form_AfterDelConfirm(Status As Integer)
    DoCmd.SetWarnings False
        If Status <> acDeleteOK Then Exit Sub
    Call Log_Eintrag("INT03-Team", "Löschung", aktWert, "Satz")
        mTxt = "Der User mit Kürzel »" & aktWert & "« wurde gelöscht."
        MsgBox mTxt, vbOKOnly, mTit
        DoCmd.Close acForm, Me.Name, acSaveNo
    End Sub
    Maybe the rsTab.Delete command is not at the right place? But how do I trigger the dialog?
    Or is it possible, that the deletion confirm dialog can only be used when deleting from a datasheet?



    Thanks for your answers,
    Walter
    Last edited by walterio; 07-02-2020 at 02:51 PM. Reason: Slash!

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    AFAIK, delete method is not applicable to a recordset in 2010 or 2013 Access.
    If you want a delete prompt, just use OpenQuery (a stored query) or RunSql and leave warnings turned on. Let Access do the work.

    You must have typed in your own code tags? Slash direction is wrong, methinks.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    Using DAO recordset.delete method does not trigger a prompt (https://docs.microsoft.com/en-us/off...-dao-recordset).
    In addition to the action query suggested by Micron you could open a pop-up form, find the record and delete it in that form (to which you add your existing code for the AferDelConfirm) or build your own message and add it to the first sub after you run the delete.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #4
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    Thanks for your answer.
    I think I'll drop the idea of prevention and presume the user knows what he does.

  5. #5
    walterio is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Jul 2019
    Posts
    33
    Thank you too for your answer, Vlad.
    I did thought about building my own confirm deletion dialog. I'll see, if it's necessary.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 03-11-2019, 02:35 PM
  2. Replies: 6
    Last Post: 06-27-2018, 08:07 AM
  3. Replies: 9
    Last Post: 11-29-2017, 10:27 AM
  4. Replies: 13
    Last Post: 05-06-2014, 12:42 PM
  5. Delete Query Deleting Too Much
    By TundraMonkey in forum Queries
    Replies: 6
    Last Post: 06-30-2009, 02:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums