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

OptionGroup.DefaultValue 属性 (访问)OptionGroup.DefaultValue Property (Access)

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

指定在创建新记录时自动输入到字段中的值。例如,在地址表中可以到纽约设置城市字段的默认值。当用户向表中添加记录时,他们可以接受该默认值,或输入其他城市的名称。读/写,字符串Specifies a value that is automatically entered in a field when a new record is created. For example, in an Addresses table you can set the default value for the City field to New York. When users add a record to the table, they can either accept this value or enter the name of a different city. Read/write String.

语法Syntax

表达式默认值expression. DefaultValue

表达式_一个表示选项组中的对象的变量。_expression A variable that represents an OptionGroup object.

注解Remarks

默认值属性将应用于所有的表字段,这些字段与自动编号或 OLE 对象的数据类型除外。The DefaultValue property applies to all table fields except those fields with the data type of AutoNumber or OLE Object.

默认值属性指定文本或创建新记录时自动输入字段或控件中的表达式。例如,如果设置为一个文本框控件的默认值属性为=Now(),该控件显示当前的日期和时间。默认值属性设置为的最大长度为 255 个字符。The DefaultValue property specifies text or an expression that's automatically entered in a control or field when a new record is created. For example, if you set the DefaultValue property for a text box control to =Now(), the control displays the current date and time. The maximum length for a DefaultValue property setting is 255 characters.

在选项组中时,默认值属性不能应用到复选框、 选项按钮或切换 buttoncontrols。但是适用于选项组本身。The DefaultValue property doesn't apply to check box, option button, or toggle buttoncontrols when they are in an option group. It does however apply to the option group itself.

在 Visual Basic 中使用字符串表达式来设置此属性的值。例如,以下代码将设置名为 PaymentMethod 的"现金"的文本框控件的默认值属性In Visual Basic, use a string expression to set the value of this property. For example, the following code sets the DefaultValue property for a text box control named PaymentMethod to "Cash"

Forms!frmInvoice!PaymentMethod.DefaultValue = """Cash"""

请注意 若要通过使用 Visual Basic 设置字段的此属性,请使用 ADO默认值属性或 DAO默认值属性。Note To set this property for a field by using Visual Basic, use the ADO DefaultValue property or the DAO DefaultValue property.

仅在添加新记录时,将应用默认值属性。如果更改了默认值属性,更改不会自动应用到现有的记录。The DefaultValue property is applied only when you add a new record. If you change the DefaultValue property, the change isn't automatically applied to existing records.

如果您设置窗体控件绑定到还具有定义表中的默认值属性设置的字段的默认值属性,则控件设置覆盖表设置。If you set the DefaultValue property for a form control that's bound to a field that also has a DefaultValue property setting defined in the table, the control setting overrides the table setting.

如果通过从字段列表中拖动字段创建控件时,该字段的默认值属性设置,定义在表中,应用到窗体上的控件尽管控件的默认值属性设置将保持为空。If you create a control by dragging a field from the field list, the field's DefaultValue property setting, as defined in the table, is applied to the control on the form although the control's DefaultValue property setting will remain blank.

一个控件可以为另一个控件提供默认值。例如,如果将控件的默认值属性设置为以下表达式,则该控件的默认值设置为默认值属性设置为txtShipTo控件。One control can provide the default value for another control. For example, if you set the DefaultValue property for a control to the following expression, the control's default value is set to the DefaultValue property setting for the txtShipTo control.

=Forms!frmInvoice!txtShipTo

如果这两个控件位于同一窗体上,则默认值的源控件的 Tab 键次序必须在含有表达式的控件之前。If the controls are on the same form, the control that's the source of the default value must appear earlier in the tab order than the control containing the expression.

另请参阅See also

概念Concepts

选项组对象OptionGroup Object

© 2018 Microsoft