Disable Enter and Tab key

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Any suggestions as to how to disable the Tab key and
Enter key in Access 2002.


Thanks in advance
 
If you set the form's KeyPreview property to Yes, you could use the KeyDown
event to trap the Tab and Enter keystokes and destroy them with:
KeyCode = 0


The more important question might be why you want to do this, e.g.:

1. If you need to prevent the user moving out of a control until you have
validated the entry, use the BeforeUpdate event of the control.

2. If you need to check that the user has not left controls blank, set the
field's Required property in table design.

3. If you need to run a comparison between fields or other complex
record-level validation, use the BeforeUpdate event of the *form*.

4. If you wanted to stay with the same record instead of automatically
tabbing to the next one, set the form's Cycle property to Current Record.
 
Hi Allen

Just to clarify a bit further

Using KeyCode = 0 disables all key input - we just want
Enter and Tab disabled.

Reason for doing this is that we are trying to 're-
train/re-program' 1 user, whose previous database
experience is using a DOS based database, to use the
mouse

Tom
 
Dear Tom:
Reason for doing this is that we are trying to 're-
train/re-program' 1 user, whose previous database
experience is using a DOS based database, to use the
mouse

<Chuckle> ... and here I am haranguing my students constantly to learn the
keyboard shortcuts and trying to design an application so they can
completely avoid the mouse..

Cheers!
Fred Boer
 
You're absolutely right that KeyCode = 0 disables all key input. That's why
Allen said "trap the Tab and Enter keystokes".

Private Sub Text0_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 9 Or KeyCode = 13 Then
KeyCode = 0
End Select

End Sub
 
lol...i know exactly what you mean, Fred! <g>
when you have users faced with doing a volume of data entry, it's so hard to
get those who are not experienced in data entry to keep their hands on the
keyboard and stay away from the mouse. i automatically design my forms for
smooth-flowing keyboard data entry - then it drives me crazy to watch users
go to the mouse to click on the next field during data entry, when they
could press Enter or Tab in half a heartbeat and just keep typing! (i did
data entry myself, 8 hours a day for several years, back in the day of
mainframe dummy terminal input.)
 
Thanks all - it now does excactly what I want

It was the absence of the keycodes for Tab and Enter in
Allen's reply which caused the misinterpretation.

For future refernce where can I find a full list of
keycodes?
 
Back
Top