What exactly does a user hitting the escape key do?

G

Guest

I have multiple errors which I think are related to a user hitting the escape
key.
Fields that are populated automatically by the form and are always assumed
to be present are nulls. These fields are populated in the 'BEFORE INSERT'
event. Nevertheless I have records in the table where these columns are nulls.
I do have an UNDO event which undoes things not possible automatically but
none of that code affects the fields causing my problem.

Any ideas? Is there a better way to do this?
 
J

John Spencer

Hitting the escape key twice is guaranteed to UNDO the entire form.

Hitting the escape key once will either undo the current entry if the
current control is being modified or it will undo the entire entry form.

It looks as if you will need to check the values before saving the record to
make sure they are there.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
L

Linq Adams via AccessMonster.com

Or, if you don't care about the user having the ability to use the <Escape>
key, you can keep it from doing anything.

In Design View, for the form goto Properties - Events and scroll down and set
Key Preview to YES and then in the code window (VBA Code Editor) place:

Private Sub form_keydown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then KeyCode = 0
End Sub

Then when the user presses <Escape> nothing will happen!
 

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