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