By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,481 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,481 IT Pros & Developers. It's quick & easy.

AllowEdits=false and OnKeyDown event

P: n/a
I have created a form that has where the AllowEdits=false. When the
users try to edit and of the fields on the form, I want a Beep Sound.
Tried:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Me.AllowEdits = False Then
DoCmd.Beep
End If

End Sub
But it seems like the KeyDown event doesn't occur when
AllowEdits=false. Any other way to make a beep sound when a user tries
to edit a field?

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
A different way around this problem could be to put a label on your
form that says something like "Data on this form is NOT editable" and
then in the Load event of the form, you could set the visible property
of the label.

Me.lblWarning.Visible=Not Me.AllowEdits

Nov 13 '05 #2

P: n/a
If you set the KeyPreview property of your form to Yes/True and then
this event will fire.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Not Me.AllowEdits Then
DoCmd.Beep
MsgBox "data not editable"
End If
End Sub

So I guess that if the AllowEdits property is False and you don't use
KeyPreview, the keystrokes just get ignored...

Moral of the story - set KeyPreview to True, and then there will be
something "listening" for the keystrokes and you can trap for them...

Okay, back to my village now...

Nov 13 '05 #3

P: n/a

pi********@hotmail.com wrote:
If you set the KeyPreview property of your form to Yes/True and then
this event will fire.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If Not Me.AllowEdits Then
DoCmd.Beep
MsgBox "data not editable"
End If
End Sub

So I guess that if the AllowEdits property is False and you don't use
KeyPreview, the keystrokes just get ignored...

Moral of the story - set KeyPreview to True, and then there will be
something "listening" for the keystrokes and you can trap for them...

Okay, back to my village now...

KeyPreview did the trick. Thanks!

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.