Link to home
Start Free TrialLog in
Avatar of J.R. Sitman
J.R. SitmanFlag 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?
Avatar of Lansing Nye-Madden
Lansing Nye-Madden
Flag of United States of America image

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)
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.
Does this information get included in the database file or only with the particular Access Client that is accessing the database?
Avatar of J.R. Sitman


will that setting apply to all fields?   If so I do not want that.
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Sorry, Lansing, it does work.