Constant | Description |
dbAutoIncrField | The field value for new records is automatically incremented to a unique Long integer that can't be changed (in a Microsoft Jet workspace, supported only for Microsoft Jet database(.mdb) tables). |
dbDescending | 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 Jet workspaces only). |
dbFixedField | The field size is fixed (default for Numeric fields). |
dbHyperlinkField | The field contains hyperlink information (Memo fields only). |
dbSystemField | The field stores replication information for replicas; you can't delete this type of field (Microsoft Jet workspaces only). |
dbUpdatableField | The field value can be changed. |
dbVariableField | The field size is variable (Text fields only). |
Constant | Description |
dbRelationUnique | The relationship is one-to-one. |
dbRelationDontEnforce | The relationship isn't enforced (no referential integrity). |
dbRelationInherited | The relationship exists in a non-current database that contains the two linked tables. |
dbRelationUpdateCascade | Updates will cascade. |
dbRelationDeleteCascade | Deletions will cascade. |
Constant | Description |
dbAttachExclusive | For databases that use the Microsoft Jet database engine, the table is a linked table opened for exclusive use. You can set this constant on an appended TableDef object for a local table, but not on a remote table. |
dbAttachSavePWD | For databases that use the Microsoft Jet database engine, the user ID and password for the remotely linked table are saved with the connection information. You can set this constant on an appended TableDef object for a remote table, but not on a local table. |
dbSystemObject | The table is a system table provided by the Microsoft Jet database engine. You can set this constant on an appended TableDef object. |
dbHiddenObject | The table is a hidden table provided by the Microsoft Jet database engine. You can set this constant on an appended TableDef object. |
dbAttachedTable | The table is a linked table from a non-ODBC data source such as a Microsoft Jet or Paradox database (read-only). |
dbAttachedODBC | The table is a linked table from an ODBC data source, such as Microsoft SQL Server (read-only). |
If the Field object belongs to an | Then Attributes is |
Index object | 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 object | Read-only. |
Recordset object | Read-only. |
Relation object | Not supported. |
TableDef object | Read/write. |
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
Example (Microsoft Access)
The following example checks the Attributes property for each table in the current database, and prints the names of system and hidden tables provided by the Microsoft Jet database engine.
Note that the And operator performs a bitwise comparison to determine whether an attribute is currently set.
Sub CheckAttributes()
Dim dbs As Database, tdf As TableDef
' Return reference to current database.
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
' Compare property setting and constant in question.
If (tdf.Attributes And dbSystemObject) Or _
(tdf.Attributes And dbHiddenObject) Then
Debug.Print tdf.Name
End If
Next tdf
Set dbs = Nothing
End Sub