Adding records in a form - Escaping

  • Thread starter Thread starter szag via AccessMonster.com
  • Start date Start date
S

szag via AccessMonster.com

I have a large form that someone might add alot of tedious/detailed
information to, but if they happened to slip up and hit escape it removes all
their data throughout the form not just the one field. I realize why this
happens but is there any work around that you know of. I probably could use
the events tab but I would have to do it for every field.
 
You could set the form's KeyPreview property to Yes, and then use the form's
KeyDown event to trap and destroy the Esc keystroke:
If KeyCode = 27 Then
KeyCode = 0
End If

The might be better ways to achieve the result. For example, of you have
many dozens of field, some of them would probably be better off in a related
table.
 
Thanks. I am a bit of a novice so what exactly am I doing with:

If KeyCode = 27 Then
KeyCode = 0
End If


Allen said:
You could set the form's KeyPreview property to Yes, and then use the form's
KeyDown event to trap and destroy the Esc keystroke:
If KeyCode = 27 Then
KeyCode = 0
End If

The might be better ways to achieve the result. For example, of you have
many dozens of field, some of them would probably be better off in a related
table.
I have a large form that someone might add alot of tedious/detailed
information to, but if they happened to slip up and hit escape it removes
[quoted text clipped - 3 lines]
use
the events tab but I would have to do it for every field.
 
Open the form in design view.

Open the Properties box (View menu.)

Make sure it's title bar indicates you are looking at the properties of the
form (not of a text box.)

On the Event tab of the Properties box, set the forms KeyPreview property
to:
Yes
and set the On Key Down property to:
[Event Procedure]

Click the Build button (...) beside the property.
Access opens a code window.
Put the 3 lines in there, between the "Private Sub..." and "End Sub" lines.

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

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

szag via AccessMonster.com said:
Thanks. I am a bit of a novice so what exactly am I doing with:

If KeyCode = 27 Then
KeyCode = 0
End If


Allen said:
You could set the form's KeyPreview property to Yes, and then use the
form's
KeyDown event to trap and destroy the Esc keystroke:
If KeyCode = 27 Then
KeyCode = 0
End If

The might be better ways to achieve the result. For example, of you have
many dozens of field, some of them would probably be better off in a
related
table.
I have a large form that someone might add alot of tedious/detailed
information to, but if they happened to slip up and hit escape it
removes
[quoted text clipped - 3 lines]
use
the events tab but I would have to do it for every field.
 
Back
Top