vba 如何在未绑定表单上创建多值组合框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1570745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 10:53:18  来源:igfitidea点击:

How can I create a Multiple Value Combo box on an Unbound Form

ms-accessvbacomboboxms-access-2007

提问by Jaffal

I need your help on MS Access 2007.

我需要您在 MS Access 2007 方面的帮助。

I have a big problem with my MS Access Unbound Form. How can I create a combo box i do not want bound to a table, show a multiple value List?

我的 MS Access 未绑定表单有一个大问题。如何创建一个我不想绑定到表格的组合框,显示一个多值列表?

The Combo is named Sector and want these values to be selected in Multiples 9Which should be possible in Access 2007) from the Drop Down List: Fertilizer, Seeds, Pesticides, Veterinary products, Animal Feed, General.

Combo 被命名为 Sector 并希望在 Multiples 9 中选择这些值,这在 Access 2007 中应该是可能的)从下拉列表中选择:肥料、种子、农药、兽医产品、动物饲料、一般。

Which Select Statement or VBA code can I use. I need a solution to handle this please.

我可以使用哪个 Select 语句或 VBA 代码。我需要一个解决方案来处理这个问题。

回答by bonCodigo

Precisely a ListBox control will help you. Since you are using it in MS Access - it makes it much easier with the wizard where you can type the items list. Or if you want to use VBA, then you can load the list using AddItem property of ListBox control in the Form_Load event.

正是 ListBox 控件将帮助您。由于您在 MS Access 中使用它 - 使用向导可以更轻松地键入项目列表。或者,如果您想使用 VBA,则可以在 Form_Load 事件中使用 ListBox 控件的 AddItem 属性加载列表。

回答by Charlie R

Here is one way of doing what you want: Open up the table your Form will use. Then: Datasheet view, Datasheet Tab, Lookup Column. Select option: I will type in ... Next Under Col1 enter one of the user choices you want; for example A Dogs, then under that enter another choice; for example B Cats, etc Next give your lookup column label a name or stay with the default. Finally, Check Allow Multiple Values box. Finish. You now have a table with a combo box that allows the user to select 0, 1 or many choices. But you want it on a Form. Create Tab, Click Form. You now have a Form that has a multi value combobox. But you want it on a form you already created. Right click the ComboBox. Copy. Close the table and open the form you want the ComboBox to be a part of. Right click on a clean part of the form and Paste. Hope this is what you were looking for.

这是您想要的一种方法:打开您的表单将使用的表格。然后:数据表视图、数据表选项卡、查找列。选择选项: I will type in ... Next 在 Col1 下输入您想要的用户选项之一;例如 A Dogs,然后在该选项下输入另一个选项;例如 B Cats 等 接下来为您的查找列标签命名或保留默认值。最后,选中允许多个值框。结束。您现在有一个带有组合框的表格,允许用户选择 0、1 或多个选项。但是你想要它在一个表格上。创建选项卡,单击表单。您现在拥有一个包含多值组合框的表单。但是您希望在您已经创建的表单上使用它。右键单击组合框。复制。关闭表格并打开您希望 ComboBox 成为其中一部分的表单。右键单击表单的干净部分并粘贴。