access multivalued field combobox from vba

I

icccapital

i have a combobox on my form that is linked to a multivalued field in my
table in access 2007. There is one item selected in the multivalued field
and in the combobox, which all is working well.

How can I access the selected data from vba. When i type debug.print
me.clientservice.itemselected.count, the count is 0.

Thanks for the help.
 
D

Dirk Goldgar

icccapital said:
i have a combobox on my form that is linked to a multivalued field in my
table in access 2007. There is one item selected in the multivalued field
and in the combobox, which all is working well.

How can I access the selected data from vba. When i type debug.print
me.clientservice.itemselected.count, the count is 0.

I know. The ItemsSelected collection only seems to have anything in it when
the combo box has the focus and has been dropped down, and hasnb't lost the
focus since it was dropped down. I think this is a bug.

However, the Value property of such a combo box is a Variant Array. I can't
recall offhand, and can't check at the moment, whether that's an array of
bound-column values, or of list-row numbers, but you should be able to
determine that pretty quickly and get what you want from it.
 
I

icccapital

Dirk, thanks that is useful. I didn't realize that was an array, so now I
can get the selected items read from the list. Any thoughts on how to change
the items selected? So if I have matt and steve selected, but I don't want
any of them selected, how might I go about that? I tried to set the value(0)
and value(1), but with no success. Thanks
 
I

icccapital

Solution: on a whim I tried the reverse where I took a variant array filled
with values and assigned it to the combobox.value and that seemed to select
and deselect the correct items from the list.

ie
va(0) = "jeff"
va(1) = "jim"
me.person.value = va

now jeff and jim are selected and no long mike. Hope that helps someone.
 

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