Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2008

Tip: Looking for answers? Try searching our database.

select item in listbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
neouia777@gmail.com - 29 Mar 2008 13:10 GMT
Hi i have listbox in form i like make the listbox.text = the first
item. pls help me
Dirk Goldgar - 29 Mar 2008 14:12 GMT
> Hi i have listbox in form i like make the listbox.text = the first
> item. pls help me

For a single-select listbox:

   With lstYourListboxName
       .Value = .ItemData(Abs(.ColumnHeads))
   End With

If you know it won't have column headers:

   With lstYourListboxName
       .Value = .ItemData(0)
   End With

For a multiselect list box:

   With lstYourListboxName
       .Selected(Abs(.ColumnHeads)) = True
   End With

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Linq Adams - 29 Mar 2008 17:39 GMT
YourListBox.SetFocus
YourListBox.ListIndex = 0

Signature

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

Answers/posts based on Access 2000/2003

Dirk Goldgar - 29 Mar 2008 21:19 GMT
> YourListBox.SetFocus
> YourListBox.ListIndex = 0

Note that:

1. This doesn't work for multiselect list boxes.  For them, the ListIndex
property is independent of the items selected.

2. This method requires you to setfocus to the list box, when otherwise you
wouldn't have to.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Linq Adams - 29 Mar 2008 22:20 GMT
Actually, it does work for Multi-select Extended, not for Simple, but you're
right about setting focus. But after doing so, you can then set focus
elsewhere and the selection remains.

Signature

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

Answers/posts based on Access 2000/2003

Dirk Goldgar - 29 Mar 2008 22:38 GMT
> Actually, it does work for Multi-select Extended, not for Simple, but
> you're
> right about setting focus. But after doing so, you can then set focus
> elsewhere and the selection remains.

You're right -- I'd forgotten about extended mode, probably because I never
use it.  I still don't much care for solutions that require setting the
focus to a control, especially when you don't need to.  But as long as we're
counting up different ways to to skin cats, your suggestion certainly
qualifies.

I wonder if there are any others ...

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.