Put cursor at end of text after F9 (1 Viewer)

cdev

New member
Local time
Today, 02:42
Joined
Jul 29, 2021
Messages
1
I regularly use f9 in Access to refresh the data and thus make it so if I accidentally hit esc I don't lose as much. It is annoying though to have to click at the end of the text since after refreshing the data, it selects all the text. I want an easy way to refresh the data and then keep typing where I left off (which is primarily at the very end)
 

theDBguy

I’m here to help
Staff member
Local time
Today, 01:42
Joined
Oct 29, 2018
Messages
21,357
Hi. Welcome to AWF!

I suppose maybe it's possible to use an Autokeys macro to refresh and then set the cursor position afterwards, but I can't test that theory right now.

Sent from phone...
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:42
Joined
Feb 19, 2002
Messages
42,970
Where the cursor ends up when focus enters a field is controlled by a setting in Access. Beginning, slelect all, end.
EnterField.JPG
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 16:42
Joined
May 7, 2009
Messages
19,169
create an AutoKeys macro that will RunCode a function
that will Refresh your data and put the cursor at the end
of text of the current field.
Paste on a Module:
Code:
Public Function fnRefresh()
    Dim ctl As Control
    On Error GoTo err_handler
    DoCmd.RefreshRecord
    Set ctl = Screen.ActiveControl
    If TypeOf ctl Is TextBox Then
        ctl.SelStart = Len(ctl)
    End If
err_handler:
    Set ctl = Nothing
End Function

on AutoKeys macro:

Code:
Submacro: {F9}
    RunCode
      fnRefresh()
End Submacro
you might need to restart your db for the macro to take effect.
 
Last edited:

Sun_Force

Active member
Local time
Today, 17:42
Joined
Aug 29, 2020
Messages
396
I don't think you need any code to do it.
simply press F2.
The cursor jumps to the end of current textbox.
 

isladogs

MVP / VIP
Local time
Today, 08:42
Joined
Jan 14, 2017
Messages
18,186
@Sun_Force
You're correct that code isn't needed but F2 selects all the text in a textbox.
However, as you might expect clicking the End key takes you to the end of the entered text in the textbox! ;)
Similarly, the Home key will return you to the start
 

Sun_Force

Active member
Local time
Today, 17:42
Joined
Aug 29, 2020
Messages
396
@Sun_Force
You're correct that code isn't needed but F2 selects all the text in a textbox.
However, as you might expect clicking the End key takes you to the end of the entered text in the textbox! ;)
Similarly, the Home key will return you to the start

F2 is a window side short cut. Not Access. F2 selects the whole text or edit the text.
It means :
If the text in a textbox is selected and you press F2, the cursor jumps to the end of the text (gets ready for edit)
If the text in a textbox is not selected, F2 selects the text.

So if the text is not selected, I simply press F2 button two times. The first one selects the text, the second one sends the cursor to the end of text.
I try to keep my right hand on my mouse, so prefer not to use shortcuts at the right side of the keyboard.
Of course others may feel more comfortable to use home/end keys.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:42
Joined
Feb 19, 2002
Messages
42,970
So, it is a matter of whether you want to take some action on each and every field or you want to set the database default to your preference.
 

isladogs

MVP / VIP
Local time
Today, 08:42
Joined
Jan 14, 2017
Messages
18,186
So, it is a matter of whether you want to take some action on each and every field or you want to set the database default to your preference.
Or possibly that you want to use something other than the default behaviour for a specific textbox control!
 

Users who are viewing this thread

Top Bottom