List Box multiple value selection

≯℡__Kan透↙ 提交于 2020-01-12 11:42:29

问题


I have created form based on query output. I had used three comboboxes and one list box. First combobox gives me list of Dept, selection of Dept on second gives me location of that Dept (distinct), the third gives me (distinct) project from that location, then next is list box who displays the some codes of that project. The problem is I am able to select only one code from that list and get output in Excel.

If I wanted to select two values at a time, how would I do that?

If I select Multi Select from list box property than I am able to select multiple values but I am not getting output.


回答1:


When a List Box has its Multi Select property set to "None" then you can retrieve the selected value by simply referring to

Me.List0.Value

However, for multi-select List Box controls you need to iterate through the ItemsSelected collection to determine the items that are selected:

Dim ItemIndex As Variant
For Each ItemIndex In Me.List0.ItemsSelected
    MsgBox Me.List0.ItemData(ItemIndex)
Next


来源:https://stackoverflow.com/questions/17081572/list-box-multiple-value-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!