Field.Attributes Property

Access Developer Reference

Sets or returns a value that indicates one or more characteristics of a Field object. Read/write Long.

Syntax

expression.Attributes

expression   A variable that represents a Field object.

Remarks

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 Access workspace, supported only for Microsoft Access database engine database 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 Access 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 Access workspace only).

dbUpdatableField

The field value can be changed.

dbVariableField

The field size is variable (Text fields only).

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

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

Example

This example displays the Attributes property for Field, Relation, and TableDef objects in the Northwind database.

Visual Basic for Applications
  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.<strong class="bterm">Attributes</strong>
  Next fldLoop

  ' Display the attributes of the Northwind database's 
  ' relations.
  Debug.Print "Attributes of relations in " &amp; _
     .Name &amp; ":"
  For Each relLoop In .Relations
     Debug.Print "  " &amp; relLoop.Name &amp; " = " &amp; _
        relLoop.<strong class="bterm">Attributes</strong>
  Next relLoop

  ' Display the attributes of the Northwind database's 
  ' tables.
  Debug.Print "Attributes of tables in " &amp; .Name &amp; ":"
  For Each tdfloop In .TableDefs
     Debug.Print "  " &amp; tdfloop.Name &amp; " = " &amp; _
        tdfloop.<strong class="bterm">Attributes</strong>
  Next tdfloop

  .Close

End With

End Sub