Enter Key acts like a Tab Key

tkepongo

Registered User.
Local time
Today, 08:10
Joined
Jul 15, 2011
Messages
45
I have a subform that is a data entry form and I read on some other forums that when you press Enter, it will act like a Tab key and move to the next field. I want to program a textbox so that when you do press the Enter key, it will fire some code. I can't get it to work because Access sees it as a Tab key whenever I press Enter.

Is there some kind of property or workaround?
 
First make sure the Enter Key Behavior property of the textbox is set to Default. Second, what event do you have code in? I would typically use after update, which would fire with either Tab or Enter.
 
Try the following in the Field's On Key Down Event;
Code:
    If KeyCode = vbKeyReturn Then
        [COLOR="Green"]'Your Code Here[/COLOR]
    End If
 
There's also:
Code:
Me.CommandButton.Default = True
.. which you set in the Got Focus event of the textbox. Then put the code in the Click event of the button.

Set it to False in the lost focus event of the textbox.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom