Field.Attributes 属性 (DAO)
适用于:Access 2013、Office 2013
设置或返回 Field 对象的一个或多个特征。 读/写 Long。
语法
表达式 .Attributes
表达式 一个表示 Field 对象的变量。
说明
字段 对象的 Attributes 属性指定了 字段 对象所代表的字段的特征。 Attributes 属性存储为单个长整数,是以下“长”常量的总和:
常量 | 值 | 说明 |
---|---|---|
dbAutoIncrField | 16 | 新记录的字段值将自动增加到无法更改的唯一 Long 类型整数(在 Microsoft Access 工作区中,只受 Microsoft Access 数据库引擎数据库表的支持)。 |
dbDescending | 1 | 字段按降序(Z 到 A 或 100 至 0)排序;此选项仅适用于 Index 对象的 Fields 集合中的 Field 对象。 如果省略此常量,字段将按升序(A 到 Z 或 0 到 100)排序。 这是仅) Microsoft Access 工作区 (Index 和 TableDef 字段的默认值。 |
dbFixedField | 1 | 字段大小为固定值(数值字段的默认设置)。 |
dbHyperlinkField | 32768 | 字段包含超链接信息(仅限备注字段)。 |
dbSystemField | 8192 | 字段将存储副本的复制信息;不能删除这种类型的字段(仅适用于 Microsoft Access 工作区)。 |
dbUpdatableField | 32 | 可以更改字段值。 |
dbVariableField | 2 | 字段大小是可变值 (仅限文本字段)。\ |
对于尚未追加到集合中的对象,该属性是可读写的。 对于已追加的 Field 对象, Attributes 属性的可用性取决于包含 Fields 集合的对象。
如果“字段”对象属于 | 则 Attributes 为 |
---|---|
Index对象 | 读/写,直至 Index 对象追加到的 TableDef 对象追加到 数据库 对象; 然后该属性变为只读。 |
QueryDef对象 | 只读 |
记录集对象 | 只读 |
关系对象 | 不支持 |
TableDef对象 | 读/写 |
设置多个属性时,可通过对相应的常量求和来组合这些属性。 将忽略所有无效值,且不产生错误。
示例
以下示例显示 Northwind 数据库中 Field、 Relation 和 TableDef 对象的 Attributes 属性。
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