Link to home
Start Free TrialLog in
Avatar of chestera
chestera

asked on

Delete key

Hi

I am using the keydown event keycode  = vbkeyDelete when I click delete it deletes the record great.  I want to some how before deleteing ensure user wants to really delete with a yes or no if yes delete if no cancel.

chestera
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chestera
chestera

ASKER

rockiroads

Thanks will get back to you

chestera
Put the following code into the forms BeforeDelConfirm event
    dim txtResponse as string
    txtResponse = MsgBox("Are You Sure?", vbYesNo, "Deleting Record")
    If txtResponse = vbYes Then Response = vbYes Else Cancel = True

Or if you are wanting to do it in a field on a KeyDown (or similar) event use the following
    Dim txtresponse As String
    If KeyCode = vbKeyDelete Then
        txtresponse = MsgBox("Are You Sure?", vbYesNo, "Deleting Record")
        If txtresponse = vbYes Then DoCmd.RunCommand acCmdDeleteRecord
    End If
faz136

Thanks for your reply but rockiroads works fine

chestera
rockiroads

Many thanks just what i wanted. never thought of the if statement so simple. sure you have heard of the KISS principle

chestera
Keeping it sweet and simple - thats my philosophy - do the sexy work afterwards :)
get it working first of course!
rockiroads

:)