MS访问多选组合框全部选择/无 [英] MS Access Multi-select Combo Box Select All/None

查看:274
本文介绍了MS访问多选组合框全部选择/无的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到SharePoint场窗体上的组合框,组合框填入正确的但是我有困难尝试添加VBA code选择所有的选项,或取消选择所有选项。

I have a combo box on a form that is linked to a SharePoint field, the combo box populates correctly however I am having difficulty trying to add VBA code to select all of the options or to unselect all options.

通过一个标准的组合框,你可以使用:

With a standard combo box you can use:

cmbBox1.value = ""

和将重置字段。同样的事情可以与列表框具有多选启用然而此扔一个错误,该控制是只读的,不能被修改来完成,与组合框具有因为查找的多选

and that will reset the field. The same thing can be done with a list box that has multi-select enabled however this tosses an error, "This control is read-only and cannot be modified", with the combo box that has multi-select because of the lookup.

我已经做了一些搜索但似乎没有人有一个真正的答案只需要使用一个列表框来代替,而不是一个解决方案在这里。

I have done some searching however no one seems to have a real answer other than to use a listbox instead and that isn't a solution here.

有没有人曾与这些领域之一,并知道如何选择所有使用VBA的选择?

Has anyone worked with one of these fields and know how to select all of the options using VBA?

下面是描述这种类型字段的链接,但它并没有讨论如何与它使用VBA交互 - <一href="http://office.microsoft.com/en-us/access-help/use-a-list-that-stores-multiple-values-HA010031117.aspx" rel="nofollow">http://office.microsoft.com/en-us/access-help/use-a-list-that-stores-multiple-values-HA010031117.aspx.

Here is a link describing this type of field but it does not discuss how to interact with it using VBA - http://office.microsoft.com/en-us/access-help/use-a-list-that-stores-multiple-values-HA010031117.aspx.

更新:

已经有大约领域,我描述了,所以我增加了一些画面的类型有些混乱捕获,显示一个组合框,允许多选,列表框,允许多个选项,并使用该选件组合框中添加的区别

There has been some confusion about the type of field I was describing so I have added some screen captures to show the difference between a combo box that allows multiselect, a list box that allows multiple options and a combo box with the option added.

首先,我在描述现场:

二列表框中:

最后组合框:

这些图像可视化中描述的问题。正如你可以看到有一些需要选择或未选中多个复选框。通常我不会创建一个字段是这样,但高于此所描述的是如何访问除$ P $点从SharePoint的组合框,允许多项选择。

These images visualize the issue that was described. As you can see there are multiple check boxes that need to be selected or unselected. Normally I would not create a field like this but as described above this is how Access interprets a combobox from SharePoint that allows for multiple selections.

推荐答案

一吨搜索和反复试验后,我想通了。

After a ton of searching and trial and error I figured it out.

要取消选择所有的复选框是

To unselect all of the check boxes it is

cmbBox1.Value = Array()

所以用这个信息,我想通了选择,他们必须在一个数组的项目。创建具有所有这一切都在组合框中项的数组,然后设置组合框等于阵列将选择所有的项目。

So with this information I figured that to select items they have to be in an array. Creating an array with all of the items that are in the combo box and then setting the combo box equal to the array will select all of the items.

我使用碱性循环来设定数组的每个元素

I used a basic loop to set each element of the array

Dim SelVals(), i
ReDim SelVals(0 to cmbBox1.ListCount - 1)
For i = 0 to cmbBox1.ListCount - 1
     SelVals(i) = cmbBox1.Column(1,i)
Next i
cmbBox1.Value = SelVals

很明显,那么你不仅限于使用的全部内容 - 你可以指定任意阵列以及将选择的值

Obviously then you aren't limited to only using the entire contents - you could assign any array and those would be the values selected.

这篇关于MS访问多选组合框全部选择/无的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆