Is there a way to interrupt default behavior for a keystroke? (1 Viewer)

wornways

Registered User.
Local time
Today, 12:38
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.
 

Mr. B

"Doctor Access"
Local time
Today, 14:38
Joined
May 20, 2009
Messages
1,932
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.
 

qaziashfaq

New member
Local time
Today, 23:38
Joined
Nov 16, 2012
Messages
4
You can use code in this event to evaluate the key that was pressed.
 

wornways

Registered User.
Local time
Today, 12:38
Joined
Nov 14, 2012
Messages
16
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.
 

wornways

Registered User.
Local time
Today, 12:38
Joined
Nov 14, 2012
Messages
16
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.
 

Mr. B

"Doctor Access"
Local time
Today, 14:38
Joined
May 20, 2009
Messages
1,932
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.
 

wornways

Registered User.
Local time
Today, 12:38
Joined
Nov 14, 2012
Messages
16
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

Top Bottom