Index.CreateField method (DAO)

Applies to: Access 2013, Office 2013

Creates a new Field object (Microsoft Access workspaces only).

Syntax

expression .CreateField(Name, Type, Size)

expression A variable that represents an Index object.

Parameters

Name

Required/optional

Data type

Description

Name

Optional

Variant

A String that uniquely names the new Field object. See the Name property for details on valid Field names.

Type

Optional

Variant

Argument not supported for this object.

Size

Optional

Variant

Argument not supported for this object.

Return value

Field

Remarks

You can use the CreateField method to create a new field, as well as specify the name, data type, and size of the field. If you omit one or more of the optional parts when you use CreateField, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the new object, you can alter some but not all of its property settings. See the individual property topics for more details.

The type and size arguments apply only to Field objects in a TableDef object. These arguments are ignored when a Field object is associated with an Index or Relation object.

If name refers to an object that is already a member of the collection, a run-time error occurs when you use the Append method.

To remove a Field object from a Fields collection, use the Delete method on the collection. You can't delete a Field object from a TableDef object's Fields collection after you create an index that references the field.