Advice request: Retaining focus on a record-navigation listbox (1 Viewer)

Duff-Man

New member
Local time
Today, 00:53
Joined
Jun 30, 2022
Messages
7
Hi all,

I have several forms which use a listbox for record navigation (in addition to forward/back buttons). The listbox works well when navigating the form via mouse & keyboard; however, some users of the form prefer to enter data via keyboard only.

When tabbing into the listbox, I would ideally like to be able to scroll through the records without losing focus on the listbox, and retaining the highlighted row position.

Alternatively, it would be fine to scroll through the listbox without switching records, and require the user to press Enter to jump to a record, and lose focus.

Any advice on how I might best approach this? Thanks.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:53
Joined
May 7, 2009
Messages
19,229
if you like you can add a Command button that will GoTo the record (from the selected item in the listbox).
set its property to Default Button to Yes, so whenever Enter key is pressed the button will get Clicked.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:53
Joined
May 7, 2009
Messages
19,229
here is a demo. you can press "Enter" to go to the record.
you can also "double-click" on the List item to go to the record.
 

Attachments

  • ListboxAsNavigation.accdb
    568 KB · Views: 88

cheekybuddha

AWF VIP
Local time
Today, 00:53
Joined
Jul 21, 2014
Messages
2,272
I haven't looked at Arnel's sugggestion, but really you just need to add an extra command in your listbox's AfterUpdate event.

Eg if your listbox is named 'lstSelect', you can use something like:

Code:
Private Sub lstSelect_AfterUpdate()

  ' code that performs the form requery
  Me.lstSelect.SetFocus

End Sub
 

isladogs

MVP / VIP
Local time
Today, 00:53
Joined
Jan 14, 2017
Messages
18,209
I'm unclear what you are asking.
Scrolling through a listbox will not (NORMALLY) change the selected record

However, it is possible to use code to 'select' a listbox record by scrolling. See:

Also these articles may be of interest?

 

Users who are viewing this thread

Top Bottom