Solved

Delete key

Posted on 2007-03-21
7
228 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

730 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