subform "AllowDeletions = No" not working if use Delete Key

hi

I have a subform and have set AllowDeletions = No on both the parent form and sub form.

If I try to delete a record with the Menu or right mouse click it does not allow (so far so good) but if I select an entire record(s) and use the keyboard Delete key then the record(s) DO get deleted. what gives, I thought that would be disabled too??
LVL 1
LukeBAsked:
Who is Participating?
 
Rey Obrero (Capricorn1)Connect With a Mentor Commented:
first set the key preview event of the subform to yes

use this code in the keydown event of the subform

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 46 Then
    KeyCode = 0
End If
End Sub

Open in new window


or this

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDelete Then
    KeyCode = 0
End If
End Sub

Open in new window

0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
That should not be happening.  Something else is going on ...

Can you upload the db (sanitized) ?

mx
0
 
LukeBAuthor Commented:
Hi MX, not can upload easlity, is an interface linked to a SQL backend

I will try a blank form and go from scratch and see if works. But for now I will try Cap's solution to get it going for users
0
 
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
No code s/b required ....

mx
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.

All Courses

From novice to tech pro — start learning today.