Solved

Delete key

Posted on 2007-03-21
7
225 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
  • 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

810 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