>

Attributes Property

Applies To

Field Object, Relation Object, TableDef Object.

Description

Sets or returns a value that indicates one or more characteristics of a Field object, a Relation object, or a TableDef object. For an object not yet appended to a collection, this property is read/write. For an appended TableDef object, the property is read/write, although not all of the constants may be set if the object is appended, as noted below.

Settings and Return Values

The data type of the setting or return value is Long.

For a Field object, the value specifies characteristics of the field represented by the Field object and can be a sum of these constants.

Constant

Description

dbFixedField

The field size is fixed (default for Numeric fields).

dbVariableField

The field size is variable (Text fields only).

dbAutoIncrField

The field value for new records is automatically incremented to a unique Long integer that can't be changed (supported only for Microsoft Jet database tables).

dbUpdatableField

The field value can be changed.

dbDescending

The field is sorted in descending (Z to A or 100 to 0) order (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 (default).

dbSystemField

The field is a replication field (on a TableDef object) used on replicable databases and cannot be deleted.


For a Relation object, value specifies characteristics of the relationship represented by the Relation object and can be a sum of these constants.

Constant

Description

dbRelationUnique

Relationship is one-to-one.

dbRelationDontEnforce

Relationship isn't enforced (no referential integrity).

dbRelationInherited

Relationship exists in a noncurrent database that contains the two attached tables.

dbRelationUpdateCascade

Updates will cascade.

dbRelationDeleteCascade

Deletions will cascade.


Note

If you set the Relation object's Attributes property to activate cascade operations, the Microsoft Jet database engine automatically updates or deletes records in one or more other tables when changes are made to related primary key tables.

For example, suppose you establish a cascade delete relationship between a Customers table and an Orders table. When you delete records from the Customers table, records in the Orders table related to that customer are also deleted. In addition, if you establish cascade delete relationships between the Orders table and other tables, records from those tables are automatically deleted when you delete records from the Customers table.

For a TableDef object, value specifies characteristics of the table represented by the TableDef object and can be a sum of these Long constants.

Constant

Description

dbAttachExclusive

For databases that use the Jet database engine, indicates the table is an attached table opened for exclusive use. This constant can be set on an appended TableDef object for a local table, but not for a remote table.

dbAttachSavePWD

For databases that use the Jet database engine, indicates that the user ID and password for the remotely attached table are saved with the connection information. This constant can be set on an appended TableDef object for a remote table, but not for a local table.

dbSystemObject

Indicates the table is a system table provided by the Jet database engine. This constant can be set on an appended TableDef object.

dbHiddenObject

Indicates the table is a hidden table provided by the Jet database engine. This constant can be set on an appended TableDef object.

dbAttachedTable

Indicates the table is an attached table from a non-ODBC database, such as a Microsoft Jet or Paradox® database (read-only).

dbAttachedODBC

Indicates the table is an attached table from an ODBC database, such as Microsoft SQL Server (read-only).


Remarks

These constants are listed in the Data Access (DAO) object library in the Object Browser.

For a Field object, use of the Attributes property depends on the object that contains the Fields collection that the Field object is appended to, as shown in the following table.

Object appended to

Usage

Index

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

Read-only

Recordset

Read-only

Relation

Not supported

TableDef

Read/write


For a Relation object, the Attributes property setting is read-only for an object appended to a collection.

When setting multiple attributes, you can combine them by summing the appropriate constants. Any nonmeaningful values are ignored without producing an error. For example, to use the Attributes property to make the Text field represented by a new Field object variable-sized and changeable, you can use this code:


fldLastName.Attributes = dbVariableField + dbUpdatableField
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 Database variable that points 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
End Sub