A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

listbox and set focus



 
 
Thread Tools Display Modes
  #1  
Old September 18th, 2009, 03:31 AM posted to microsoft.public.access.forms
seeker
external usenet poster
 
Posts: 133
Default listbox and set focus

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?


  #2  
Old September 18th, 2009, 04:02 AM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default listbox and set focus

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

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200909/1

  #3  
Old September 19th, 2009, 04:36 AM posted to microsoft.public.access.forms
seeker
external usenet poster
 
Posts: 133
Default listbox and set focus

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?

"Linq Adams via AccessMonster.com" wrote:

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

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200909/1


  #4  
Old September 19th, 2009, 12:45 PM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default listbox and set focus

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.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200909/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:33 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.