Cancel keystrokes

G

giannis

I have a form and i dont want the user
press Tab, PgDwn, Pgup and Space.
How can cancel these keystrokes ?
 
J

Joseph Meehan

And I spend hours trying to explain to users that tab, page up and page
down are great tools. All they seem to know is enter.
 
D

Drew

Use the KEYDOWN event on the control and the SELECT CASE
to filter the KEYS...

Private Sub controlname_KEYDOWN(KeyCode as Integer, Shift
as Integer) 'this comes up automatically

Select Case Keycode

Case 9 ' Tab Event

KeyCode = 0

Case 32 ' Space Bar

KeyCode = 0

Case 40, 38 ' Up and Down Arrow

KeyCode

Case else

end select

End sub


This will keep anything from happening when those keys
are pressed. You can put them all together in one Case
Statement, with a comma separator like in Case 40, 38 ...
but I broke them out to show you the different key values
and to show you that you can use the Case for many
different things.

Have FUN!!

Drew
 
A

Albert D. Kallal

In addition to the other comments here, you might actually be trying to
prevent record movement, and not actually kill to those keystrokes.

If you want the table key to cycle round and round in the same form, then in
the form other tab, set the forms cycle property to current record. Then,
when you get to the last field on the form, the tab key (or Enter key) will
jump to the top of the screen.

It is a little harsh and goes against the windows standard UI to kill the
tab key, when that has been the defacto standard FOR AT LEAST 10 YEARS.

It is a sure sign of some terrible software design if the tab key has to be
disabled. I cannot imagine the frustration you going to place on your users
when they start hitting tab key, and the cursor does not advance? Further,
for things like memo fields etc, you can set the Enter key to start a new
line, and thus the users really do need the tab key to go the next field. I
would *really* think hard about removing one of the most common keys for
navigation in a form. Your users will hate you for this....
 
D

Drew

Agree with all your comments! Also, there are other ways
to prevent record movement.
 
D

Dave Elliott

Suggest you goto Tools/Options and select Keyboard, then click on Move after
enter and select dont move.
Hope this helps, Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top