We help IT Professionals succeed at work.

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

J.R. Sitman
J.R. Sitman asked
on
64 Views
Last Modified: 2019-03-29
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?
Comment
Watch Question

Lansing Nye-MaddenNetwork Administrator
CERTIFIED EXPERT

Commented:
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)
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018

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

    Next field

to:

    Do not move

Click OK and relaunch.
Lansing Nye-MaddenNetwork Administrator
CERTIFIED EXPERT

Commented:
Does this information get included in the database file or only with the particular Access Client that is accessing the database?
J.R. SitmanIT Director

Author

Commented:
will that setting apply to all fields?   If so I do not want that.
Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
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. SitmanIT Director

Author

Commented:
Sorry, Lansing, it does work.
J.R. SitmanIT Director

Author

Commented:
Thanks
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
You are welcome