在 ms-access 中引用列表框中的多个选定项目 [英] Refer to multiple selected Items in a listbox in ms-access
本文介绍了在 ms-access 中引用列表框中的多个选定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在列表框中选择多个项目,然后参考我选择的项目?
How do I select multiple items in the list box, then refer to the Items I have selected?
推荐答案
您将需要使用以下步骤的变体:
You will need to use a variation of the following steps:
在表单上创建一个列表框
create a list box on a form
使用行源填充列表框.
然后我使用了以下 VBA
I then used the following VBA
Option Compare Database
Private Item_IDs as string
Private Sub List_item_id_Click()
Dim i As Integer, count As Integer
Dim Item_IDs As String
count = 1
For i = 0 To Me.List_item_id.ListCount - 1
If Me.List_item_id.Selected(i) = True Then
Item_IDs = Item_IDs & ", " & Me.List_item_id.ItemData(i)
count = count + 1
End If
Next i
Item_IDs = Mid(Item_IDs, 3)
Debug.Print Item_IDs
End Sub
现在每次我点击列表中的一个值时,它都会返回我选择的东西的逗号分隔值字符串(Item_IDs).在 VBA 窗口中使用 CTRL+G 打开即时窗口并查看您的劳动成果.
Now every time I click on a value in the list, it will return the a comma separated value string (Item_IDs) of the things I have selected. Use CTRL+G in the VBA window to open the immediate window and see the fruits of your labors.
这篇关于在 ms-access 中引用列表框中的多个选定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文