Solved

Delete key

Posted on 2007-03-21
7
229 Views
Last Modified: 2008-02-01
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
Comment
Question by:chestera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 50 total points
ID: 18769394
if msgbox("Do you really wanna delete?",vbyesno,"Confirm")=vbyes then
    'do your delete
end if
0
 

Author Comment

by:chestera
ID: 18769475
rockiroads

Thanks will get back to you

chestera
0
 
LVL 2

Expert Comment

by:faz136
ID: 18769485
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:chestera
ID: 18769506
faz136

Thanks for your reply but rockiroads works fine

chestera
0
 

Author Comment

by:chestera
ID: 18769515
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
 
LVL 65

Expert Comment

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

Author Comment

by:chestera
ID: 18769571
rockiroads

:)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question