Is there a way to interrupt default behavior for a keystroke?

wornways

Registered User.
Local time
Today, 00:56
Joined
Nov 14, 2012
Messages
16
Hi Folks,

I want to control the behavior for pressing the Space bar or the Enter key in multi-select ListBox. Is it possible to do this?

For instance, the default behavior for pressing the space bar is to select/deselect the item currently in focus. I want to move this behavior to the Enter key and use the space bar for something else.

Any assistance will be appreciated.

Thanks.
 
Check out the "On Key Press" event of your form. You can use code in this event to evaluate the key that was pressed and then take the action you need based on the key that was pressed.
 
You can use code in this event to evaluate the key that was pressed.
 
I can catch and change the behavior of the Space bar just fine, but the Enter key seems to be a special case that has some inner workings associated with it that just can't be bypassed. I've tried various evaluations under KeyDown, KeyUp and KeyPress, and combinations of the same, but the default behavior for Enter always fires.
 
Oh wait, never mind, there seems to also be an ListBoxControlName_Enter routine I can play with. I'll report back if I manage to get things working the way I want.
 
Be aware that there is a default action on each form when the enter key is pressed. You can change that behavior in the Options setting.
 
I think I'm making progress, folks. Just putting nothing inside ListBoxName_Enter seems to do the trick, letting me manage the behavior I want for Enter in ListBoxName_KeyDown or KeyUp. You know? It is extremely difficult to get Access 2007 forms to behave exactly the way you want them to. :D
 

Users who are viewing this thread

Back
Top Bottom