selecting multiple values on list box

J

jpnyc

I had a combo box with four variables, I found out that only a list box can
choose multiple values. After changing my combo box to a list box, after I
choose my two/three values how can I make those values appear on the form
like a combo box(with commas). Right now it shows either the first or last
value I chose not all of them.
 
P

PieterLinden via AccessMonster.com

jpnyc said:
I had a combo box with four variables, I found out that only a list box can
choose multiple values. After changing my combo box to a list box, after I
choose my two/three values how can I make those values appear on the form
like a combo box(with commas). Right now it shows either the first or last
value I chose not all of them.

One major difference between a combobox and a multiselect listbox is how it
stores the selection(s). a multi-select listbox stores the selected values
in a collection (.ItemsSelected), so you have to traverse the collection to
retrieve the individual values.

dim varItem as Variant '--to hold the individual value selected in the
listbox.
dim strText as string

For Each varItem in mslbx.ItemsSelected
'Process the selected item here...
strText = strText & "; " & mslbx.ItemData(varItem)
Next varItem

'trim off the initial "; "
strText = right$(strText, len(strText)-2)
me.txtShowSelections = strText
 
W

Wes

I am attempting to do the same. However, I am having no luck. Do i need to
change the name of my multiple value list box to "mslbx" and then call the
text box i am passing the string too "txtShowSelections".?

Thanks for the help.
 

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