Field.Attributes 属性 (DAO)Field.Attributes property (DAO)
09/18/2015
本文内容
适用于:Access 2013、Office 2013Applies to: Access 2013, Office 2013
设置或返回Sets or returns a value that indicates one or more characteristics of a 读/写 Long。Read/write Long.
语法Syntax
表达式 .Attributesexpression . Attributes
表达式 一个表示 Field 对象的变量。expression A variable that represents a Field object.
说明Remarks
该值指定 Field 对象表示的字段的特性,并且可以是以下常量的组合。The value specifies characteristics of the field represented by the Field object and can be a combination of these constants.
常量Constant
说明Description
dbAutoIncrFielddbAutoIncrField
新记录的字段值将自动增加到无法更改的唯一 Long 类型整数(在 Microsoft Access 工作区中,只受 Microsoft Access 数据库引擎数据库表的支持)。The field value for new records is automatically incremented to a unique Long integer that can't be changed (in a Microsoft Access workspace, supported only for Microsoft Access database engine database tables).
dbDescendingdbDescending
字段按降序(Z 到 A 或 100 至 0)排序;此选项仅适用于 Index 对象的 Fields 集合中的 Field 对象。The field is sorted in descending (Z to A or 100 to 0) order; this option applies only to a Field object in a Fields collection of an Index object. If you omit this constant, the field is sorted in ascending (A to Z or 0 to 100) order. This is the default value for Index and TableDef fields (Microsoft Access workspaces only).. 如果省略此常量,字段将按升序(A 到 Z 或 0 到 100)排序。If you omit this constant, the field is sorted in ascending (A to Z or 0 to 100) order. 这是 Index 和 TableDef 字段的默认值(仅适用于 Microsoft Access 工作区)。This is the default value for Index and TableDef fields (Microsoft Access workspaces only)..
dbFixedFielddbFixedField
字段大小为固定值(数值字段的默认设置)。The field size is fixed (default for Numeric fields).
dbHyperlinkFielddbHyperlinkField
字段包含超链接信息(仅限备注字段)。The field contains hyperlink information (Memo fields only).
dbSystemFielddbSystemField
字段将存储副本的复制信息;不能删除这种类型的字段(仅适用于 Microsoft Access 工作区)。The field stores replication information for replicas; you can't delete this type of field (Microsoft Access workspace only).
dbUpdatableFielddbUpdatableField
可以更改字段值。The field value can be changed.
dbVariableFielddbVariableField
字段大小是可变值(仅限文本字段)。The field size is variable (Text fields only).
对于尚未追加到集合中的对象,该属性是可读写的。对于已追加的 Field 对象, Attributes 属性的可用性取决于包含 Fields 集合的对象。For an object not yet appended to a collection, this property is read/write. For an appended Field object, the availability of the Attributes property depends on the object that contains the Fields collection.
如果 Field 对象属于If the Field object belongs to an
则 AttributesThen Attributes is
Index 对象Index object
读/写,直至 Index 对象追加到的 TableDef 对象追加到 Database 对象;然后该属性变为只读。Read/write until the TableDef object that the Index object is appended to is appended to a Database object; then the property is read-only.
QueryDef 对象QueryDef object
只读Read-only
Recordset 对象Recordset object
只读Read-only
Relation 对象Relation object
不支持Not supported
TableDef 对象TableDef object
读/写Read/write
设置多个属性时,可通过对相应的常量求和来组合这些属性。将忽略所有无效值,且不产生错误。When you set multiple attributes, you can combine them by summing the appropriate constants. Any invalid values are ignored without producing an error.
示例Example
以下示例显示 Northwind 数据库中 Field、 Relation 和 TableDef 对象的 Attributes 属性。This example displays the Attributes property for Field, Relation, and TableDef objects in the Northwind database.
Sub AttributesX()
Dim dbsNorthwind As Database
Dim fldLoop As Field
Dim relLoop As Relation
Dim tdfloop As TableDef
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
With dbsNorthwind
' Display the attributes of a TableDef object's
' fields.
Debug.Print "Attributes of fields in " & _
.TableDefs(0).Name & " table:"
For Each fldLoop In .TableDefs(0).Fields
Debug.Print " " & fldLoop.Name & " = " & _
fldLoop.Attributes
Next fldLoop
' Display the attributes of the Northwind database's
' relations.
Debug.Print "Attributes of relations in " & _
.Name & ":"
For Each relLoop In .Relations
Debug.Print " " & relLoop.Name & " = " & _
relLoop.Attributes
Next relLoop
' Display the attributes of the Northwind database's
' tables.
Debug.Print "Attributes of tables in " & .Name & ":"
For Each tdfloop In .TableDefs
Debug.Print " " & tdfloop.Name & " = " & _
tdfloop.Attributes
Next tdfloop
.Close
End With
End Sub