列表框多值选择列表、框多值

2023-09-08 10:59:31 作者:要把难过藏起来

我已经根据查询输出创建的窗体。我已经使用了三个组合框和一个列表框。第一组合框给了我部的名单,对第二选择系的给我的那部(不同)的位置,第三个给我(不同),从该位置的项目,那么接下来就是列表框中谁显示了一些codeS项目。现在的问题是,我能够从列表中选择只有一个code和获取输出在Excel中。

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.

推荐答案

在一个列表框有多选属性设置为无,那么你可以检索选定值通过简单地参照

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

然而,对于多选列表框控件,你需要遍历 ItemsSelected 集合,以确定被选定的项目:

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