listbox and set focus

S

seeker

I have a list box on a form and have the following code onload for form

Private Sub Form_Load()
Me.lbxNameSearch.SetFocus

End Sub

when the form opens it does not set focus to listbox. The first record is
not hilighted. What is wrong with above code?
 
L

Linq Adams via AccessMonster.com

Setting focus to the listbox doesn't select the first item. This will do the
job:

Private Sub Form_Load()
lbxNameSearch.SetFocus
Me.lbxNameSearch.Selected(0) = True
End Sub
 
S

seeker

Thank you that solved THAT problem. now i can not move up and down in the
list box with the arrow keys. If I click the selected record with mouse then
I can move through the listbox with arrow keys. How can I make arrow keys
work without clicking the mouse?
 
L

Linq Adams via AccessMonster.com

Is your listbox Multi-Select property set to something other than None?
That's the only way I could reproduce not being able to use the arrows to
navigate the box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top