• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

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
0
chestera
Asked:
chestera
  • 4
  • 2
1 Solution
 
rockiroadsCommented:
if msgbox("Do you really wanna delete?",vbyesno,"Confirm")=vbyes then
    'do your delete
end if
0
 
chesteraAuthor Commented:
rockiroads

Thanks will get back to you

chestera
0
 
faz136Commented:
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
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
chesteraAuthor Commented:
faz136

Thanks for your reply but rockiroads works fine

chestera
0
 
chesteraAuthor Commented:
rockiroads

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

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

:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now