Disable All Shortcut Keys - In Access 97

  • Thread starter Thread starter Jado
  • Start date Start date
J

Jado

Hi

I have a form that opens with a database, and when the from is closed, it
automatically exits the database. This keeps the users away from the
underling tables queries and code.

but if a user knows how, or hits a set of keys by mistake, it is possible to
bring up the database window along with a load of other undesired shortcut
features.

Probably the most worrying is Ctrl+A (Select All) which actually selects
every record in the underlying recordset. if a user then presses another
key, the database tries to delete all records (which are unrecoverable).
This has never happened, but I'd like to prevent it before it dose.

Is it possible to disable these types of shortcut keys.

I'd like to leave Cut, Copy, Paste shortcuts working if possible.


Thanks

Jado
 
A simple way to disable a keystroke application wide is to reassign it to
something innocuous.

1. Create a new macro.

2. If you do not see a Macro Names column, choose Macro Names on the View
menu.

3. In the Macro Name column, enter:
^A
(Note: Use Shift+6 to get the caret character.)

4. In the Action column, choose an action such as:
Beep

5. Save the macro with the name:
AutoKeys
The correct name is important.

Now whenever the user presses Ctrl+A, the computer beeps and does not select
all records.

If you just wanted to do that for one form, you could turn on the form's
KeyPreview property, and use the KeyPress event to set KeyAscii to 0.
 
Thanks Allen

Do you know of a source that lists all default shortcut keys in Access 97 /
Win2000?

in the mean time i'll take a look on the internet.

also, do you know if there's a VBA equivillent of AutoKeys. I would rarther
use this feature in startup code. That way i could set limitations based on
current user. i'll try converting the macro to code and see what happens!

i don't fully understand the last part of your reply
If you just wanted to do that for one form, you could turn on the form's
KeyPreview property, and use the KeyPress event to set KeyAscii to 0.

what would this do?

Thanks Again

Jado
 
You can trap the keystrokes in a form. Use the form's KeyPress event if you
are interested in the charater, or KeyDown event to trap non-character
strokes such as PgDn or Del. By setting the argument to zero in the event,
you destroy the keystroke before it is processed.

This example stops the Esc key from undoing a form or its controls:

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


(Don't forget to turn on the form's KeyPreview property.)
 
That's alot clearer

Thanks Allen

Jado

Allen Browne said:
You can trap the keystrokes in a form. Use the form's KeyPress event if you
are interested in the charater, or KeyDown event to trap non-character
strokes such as PgDn or Del. By setting the argument to zero in the event,
you destroy the keystroke before it is processed.

This example stops the Esc key from undoing a form or its controls:

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


(Don't forget to turn on the form's KeyPreview property.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

97 based
 
Back
Top