How to Kick Off Code when a user hits escape

catbeasy

Registered User.
Local time
Today, 07:29
Joined
Feb 11, 2009
Messages
140
Would like to be able to reset a combo box when a user hits escape and so resets the text boxes.

So for example, a user selects a value from a combo box, then enters a value in a text box, but then decides doesn't want that value, so hits escape.

On the 'on escape' event I would like to know how to kick off my code that will reset the combo box to null?

Thanks for any assistance..
 
If the combo is bound, hitting escape should clear it too. If not bound then put

Me.YourComboBoxNameHere = Null

in the form's UNDO event.
 
If the combo is bound, hitting escape should clear it too. If not bound then put

Me.YourComboBoxNameHere = Null

in the form's UNDO event.

I don't see an undo event in the form's event tab listings. I am using Access 97. Is it perhaps not available in Access 97?

Thanks..
 
I don't see an undo event in the form's event tab listings. I am using Access 97. Is it perhaps not available in Access 97?

Thanks..

That's a good chance. I don't have Access 97 to verify, but you should check within the VBA window as not all events are available on the properties dialog. Go into the VBA window and then go up to the drop downs and select FORM and then over on the right side check the events that are listed in that drop down.
 
That's a good chance. I don't have Access 97 to verify, but you should check within the VBA window as not all events are available on the properties dialog. Go into the VBA window and then go up to the drop downs and select FORM and then over on the right side check the events that are listed in that drop down.
Doesn't look like its available. Any other suggestions?
 
Provided the form has a Key Down event, you could try putting this there:

Code:
    If KeyCode = 27 Then
        Me.YourComboNameHere = Null
    End If

make sure the form's KEY PREVIEW property is set to YES (don't know if that is applicable to Access 97 or not but it is for later versions).
 
Provided the form has a Key Down event, you could try putting this there:

Code:
    If KeyCode = 27 Then
        Me.YourComboNameHere = Null
    End If

make sure the form's KEY PREVIEW property is set to YES (don't know if that is applicable to Access 97 or not but it is for later versions).

That worked. But I still have another issue. After the user hits escape, I want the controls to lock, until they do something else. I have the code to do the lock, but what happens is that I get an error when trying to run it with the keydown event..

The error is that I can't lock a control while it has unsaved changes. So, wondering how do I 'save' the changes, in this case, save the revoking of a record, so I can then lock the controls?

Thanks for your continued assistance..
 
Not sure about that one.
Will a

Me.Undo

work for you?
 

Users who are viewing this thread

Back
Top Bottom