Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box to support multiple selection 4

Status
Not open for further replies.

Smitty020

MIS
Jun 1, 2001
152
0
0
US
I have a list box populated from a DB using ADO. How can I get it to support multiple selections??

Thanks in advance!
 
In the listbox properties window, all you need to do is modify the multiselect property. You can change it to "1-Simple" or "2-Extended". The simple setting lets you choose multiple entries without holding down the control key. When set to extended, you need to hold the control key down when selecting your second, third, etc choices.

Hope this helps.
 
ok, I tried that, but when I run it, it switches back to 0 in the multiselect line. Any ideas??

Thanks!
 
You need to populate the listbox manually, with-out connecting to a recordset.

Just loop through the recordset and for each record, use the ListBox1.AddItem method.

rs.MoveFirst
Do Until rs.Eof
ListBox1.AddItem rs(""myField)
rs.movenext
Loop
ListBox1.MultiSelect = True

Then you can do what you want to do.... [/b][/i][/u]*******************************************************[sub]
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
OK, now it's giving me a compiler error saying, can't assign to a read only propoerty. When did I make it read only?

Thanks
 
listbox.multiselect property is read only at run time. You can only set it in the properties box at design time, using the dropdown. Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
johnwm,

when I selected extended on the drop down and run it, it goes back to 0. I tried saving before I ran it, but it didn't help. Could there be something else wrong?
 
What do you have the "STYLE" property set to? If it's set to checkbox, that could cause a problem. There may be some other property that's causing the multiselect to revert back to 0 but STYLE is the only one that I know of that could cause a problem.

 

Make sure that you have "unbound" your list box. The easiest thing to do is delete it and add a new list box and give it the same name. Then change the multi select property and see how that works.

Good Luck
 
Thanks vb5prgrmr, that worked! Thanks to you others also, you pointed me in the right direction! Ya'll get stars in my book!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top