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, Relation, or TableDef object.

Settings and Return Values

The setting or return value is Long data type, and the default value is 0.

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

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).


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

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.


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

For example, suppose you establish a cascading 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 cascading 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, the value specifies characteristics of the table represented by the TableDef object and can be a combination of these Long constants.

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).


Remarks

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.

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.


For an appended Relation object, the Attributes property setting is read-only.

For an appended TableDef object, the property is read/write, although you can't set all of the constants if the object is appended, as noted in Settings and Return Values.

When you set multiple attributes, you can combine them by summing the appropriate constants. Any invalid values are ignored without producing an error.

Specifics (Microsoft Access)

If you set the Attributes property of a TableDef object to dbHiddenObject, Microsoft Access hides the TableDef object. The TableDef object exists in the TableDefs collection, but you cannot see it in the Database window, even if you have selected the Show Hidden Objects option in the Options dialog, which is available by clicking on the Tools menu.

To create a TableDef object that can be either hidden or visible, set the Attributes property to dbSystemObject. You can then make the TableDef object visible in the Database window by selecting Show System Objects in the Options dialog.

Example

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
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