How to stop Delete key from deleting records?

RSW

Registered User.
Local time
Yesterday, 16:33
Joined
May 9, 2006
Messages
178
I have a form that deletes a record if the Delete key is pressed when the form's on that record.

I don't want to entirely stop the form from deleting records...because there's a Delete button that can be used for just that. But records are being deleted without warning when a user accidentally presses the Delete key. What is the best way to stop this?

Thanks in advance!
 
Set the form's KeyPreview to YES. Then in the KeyPress event of the form, put:
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        If KeyCode = 46 Then
            KeyCode = 0
        End If
End Sub
 
Thanks Bob,

I'm unclear...do you mean KeyPress or KeyDown?
 
or

set the forms delete records option to no - and add a dedicated button to delete them where you can do so under control
 
or

set the forms delete records option to no - and add a dedicated button to delete them where you can do so under control

The delete button would still work even if the delete records option was no?
 
yes - code still works - just not any of the intrinsic delete options (all of them!)
 

Users who are viewing this thread

Back
Top Bottom