Table of contents
TOC
折叠目录
展开目录

ComboBox.LimitToList 属性 (访问)ComboBox.LimitToList Property (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

限于列表属性可用于限制所列各项的组合框的值。读/写boolean 类型的值You can use the LimitToList property to limit a combo box's values to the listed items. Read/write Boolean.

语法Syntax

表达式限于列表expression. LimitToList

表达式_表示组合框对象变量。_expression A variable that represents a ComboBox object.

注解Remarks

限于列表属性使用以下设置。The LimitToList property uses the following settings.

设置SettingVisual BasicVisual Basic说明Description
YesTrueTrue如果用户从组合框中的列表中选择一项,或输入的文本与列表的项匹配,则 Microsoft Access 将接受它。如果输入的文本与列表的项不匹配,则不接受该文本,用户然后必须重新进行输入、 选择列表的项,请按 esc 键,或单击编辑菜单上的撤消If the user selects an item from the list in the combo box or enters text that matches a listed item, Microsoft Access accepts it. If the entered text doesn't match a listed item, the text isn't accepted and the user must then retype the entry, select a listed item, press ESC, or click Undo on the Edit menu.
NoFalseFalse(默认值)Microsoft Access 接受符合有效性规则属性的任何文本。(Default) Microsoft Access accepts any text that conforms to the ValidationRule property.

对于表字段,您可以设置此属性在表设计视图的字段属性部分的查阅选项卡上DisplayControl属性设为组合框。For table fields , you can set this property on the Lookup tab of the Field Properties section of table Design view for fields with the DisplayControl property set to Combo Box.

请注意 当选择查阅向导作为表设计视图中字段的数据类型时,Microsoft Access 将自动设置限于列表属性。Note Microsoft Access sets the LimitToList property automatically when you select Lookup Wizard as the data type for a field in table Design view.

当绑定的组合框中的限于列表属性设置为否时,可以不包含在该列表的组合框中输入一个值。Microsoft Access 存储在窗体的基础表或查询 (在组合框的控件来源属性中指定的字段),没有表或查询的组合框的行来源属性设置新值。要输入了新值将出现在组合框中,必须添加新的值的表或查询在行来源属性中设置通过使用宏或 Visual Basic 事件过程运行时,会发生NotInList事件。When the LimitToList property of a bound combo box is set to No, you can enter a value in the combo box that isn't included in the list. Microsoft Access stores the new value in the form's underlying table or query (in the field specified in the combo box's ControlSource property), not the table or query set for the combo box by the RowSource property. To have newly entered values appear in the combo box, you must add the new value to the table or query set in the RowSource property by using a macro or Visual Basic event procedure that runs when the NotInList event occurs.

限于列表属性和自动展开属性设置为可让 Microsoft Access 用户在组合框的文本框部分输入字符,并将条目限制为只能查找列表中的匹配值这些值。Setting both the LimitToList property and the AutoExpand property to Yes lets Microsoft Access find matching values from the list as the user enters characters in the text box portion of the combo box, and restricts the entries to only those values.

请注意 如果您设置组合框的绑定列属性而不是第一个可见列的任意列 (或如果您将绑定列都设置为 0),限于列表属性自动设置为是。Note If you set the combo box's BoundColumn property to any column other than the first visible column (or if you set BoundColumn to 0), the LimitToList property is automatically set to Yes.

限于列表属性设置为是,并在用户单击组合框旁边的箭头 Microsoft Access 选择匹配列表中的值,当用户在组合框的文本框部分输入字符时即使自动展开属性设置为 no。如果用户按 ENTER 或移到另一控件或记录,选定的值将显示在组合框中。When the LimitToList property is set to Yes and the user clicks the arrow next to the combo box, Microsoft Access selects matching values in the list as the user enters characters in the text box portion of the combo box, even if the AutoExpand property is set to No. If the user presses ENTER or moves to another control or record, the selected value appears in the combo box.

组合框接受值时的限于列表属性设置为 Yes 或True,该列表是否包含值。如果要防止用户在组合框中输入一个null值,组合框绑定到是的表中设置该字段的必填属性。Combo boxes accept null values when the LimitToList property is set to Yes or True, whether or not the list contains null values. If you want to prevent users from entering a null value in a combo box, set the Required property of the field in the table to which the combo box is bound to Yes.

通过提供的链接:社区成员图标Luke 台湾、FMS,inc.保留所有权利。Link provided by:Community Member Icon Luke Chung,FMS, Inc.

示例Example

下面的示例将给定组合框的值限制为列表项。The following example limits a given combo box's values to its listed items.

Forms("Order Entry").Controls("States").LimitToList = True  

关于参与者About the Contributors

Luke 台湾是创始人和总裁的 FMS,Inc.、 解决方案的自定义数据库和开发工具的领先提供商。Luke Chung is the founder and president of FMS, Inc., a leading provider of custom database solutions and developer tools.

另请参阅See also

概念Concepts

组合框对象ComboBox Object

© 2018 Microsoft