Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Aug 2002
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete Confirmation (2002)

    I have an Access DB that I have been given and asked to have any data deleted from the tables via forms to be confirmed before being deleted. In other words, if they delete data from a field on a form they want it to be confirmed with a pop-up asking if it is OK to delete the data. How do I do this? The switch is set in Access to "confirm document deletions" but it does not work on forms? Any help greatly appreciated! Thanks in advance for any advice [img]/forums/images/smilies/smile.gif[/img]

  2. #2
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete Confirmation (2002)

    I've set up the following that allows the user to use Function Key F3 to delete a record in any form that they want by setting up the Public Function coding and then using KeyDown in the form's module. It gives them two warnings before they destroy themselves. You could use a variation of this to accomplish your task.


    '== FKey F3 =============== Delete ===============
    Public Function keyDelete(KeyCode As Integer)
    If KeyCode = vbKeyF3 Then
    On Error GoTo Err_keyDelete_Click
    Dim intResponse As Integer
    Dim DoYouMeanIt
    DoYouMeanIt = MsgBox("Are You Absolutely Sure You Want to Delete This Record?", _
    vbYesNo, "This Record Will No Longer Exist!!")
    If DoYouMeanIt = vbYes Then
    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
    Else
    intResponse = acDataErrContinue
    End If
    Exit_keyDelete_Click:
    Exit Function
    Err_keyDelete_Click:
    MsgBox Err.Description
    Resume Exit_keyDelete_Click
    KeyCode = 0
    End If
    End Function

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    '== FKey F3 =============== Delete =============== FKey F3
    If KeyCode = vbKeyF3 Then
    Call keyDelete(KeyCode)
    End If
    End Sub
    Cheers,
    Andy

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Delete Confirmation (2002)

    The "confirm document deletions" option causes a warning to be displayed if the user tries to delete a database object such as a table, query or form from the database window.
    The "confirm record changes" option causes a warning to be displayed if the user tries to delete one or more records from a table, query or form.
    There is no option to display a warning if the user clears a field. You would have to write code in the Before Update event of each control for this. The code should display a Yes/No message box and set the Cancel argument of the event procedure to True if the update is to be canceled. But this could be very annoying to users!

    Example:

    Private Sub txtSomething_BeforeUpdate(Cancel As Integer)
    If Not IsNull(Me.txtSomething.OldValue) And IsNull(Me.txtSomething) Then
    If MsgBox("Are you sure you want to clear this field?", vbQuestion + vbYesNo) = vbNo Then
    Me.txtSomething.Undo
    Cancel = True
    End If
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •