Avatar of J.R. Sitman
J.R. Sitman
Flag for United States of America asked on

In Microsoft Access how do you prevent the cursor from going to a new field after you hit enter?

when entering data in a field that is for searching after you hit enter the cursor jumps to a different field.   I do I set it so it does not leave the search field?
Microsoft Access

Avatar of undefined
Last Comment
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

8/22/2022 - Mon
Lansing Nye-Madden

I don't have an environment set up right now that I could use to test this, so please keep that in mind, but can you utilize the event when the cursor leaves the box to place the focus back on the control that fired the event? (This may break your tab functionality and you would lose your ability to select another control)
Gustav Brock

Go to menu Files, Settings, Client settings.
Move setting in the first option, Move cursor with Enter, from:

    Next field


    Do not move

Click OK and relaunch.
Lansing Nye-Madden

Does this information get included in the database file or only with the particular Access Client that is accessing the database?
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
J.R. Sitman

will that setting apply to all fields?   If so I do not want that.
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Gustav Brock

You can do something like this:

Private Sub YourTextBox_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = vbKeyReturn Then
        KeyCode = 0

        ' Save form/record.
        If Me.Dirty = True Then
            Me.Dirty = False
        End If
        ' or call your search function. Use Text if textbox not updated, as Value is not updated.
        MySearchFunction Me!YourTextBox.Text
    End If

End Sub

Open in new window

J.R. Sitman

Sorry, Lansing, it does work.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
J.R. Sitman

DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

You are welcome