List Box multiple value selection

2019-04-02 14:47发布

问题:

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