By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,191 Members | 1,067 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,191 IT Pros & Developers. It's quick & easy.

On load select all in a list box

P: 29
Can you have a list box default to selecting all items and have people click off the ones they don't want?
Aug 5 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 903
One way to do it would be like so
Expand|Select|Wrap|Line Numbers
  1. Set lst = Me!Your_Listbox_Name
  2. itm = 0
  3. Do While itm < lst.ListCount
  4.     lst.Selected(itm) = True
  5.     itm = itm + 1
  6. Loop
Ensure your Multiselect property is set to 'Extended' and the user will see all items selected and then use the standard CTL key with mouse to unselect what they don't want.

Aug 5 '08 #2

Expert Mod 15k+
P: 31,494
For ... Each would work nicely for this too :
Expand|Select|Wrap|Line Numbers
  1. Dim objItem As Object
  3. For Each objItem In Me.Your_Listbox_Name.Selected
  4.   objItem = True
  5. Next objItem
Aug 9 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.