CreateField Method

Creates a new Field object.

Applies to objects: Index, Relation, TableDef.

Syntax

[[Set] RetVal = ] object.CreateField([Name], [Type], [Size])

The MethodName method syntax has these parts:

Part Description
object Required. A reference to an instance of the object.
RetVal Optional. A Field type variable.
Name Optional. A String type variable. The name of the field, being created.
Type Optional. A Long type variable. The type of the field.
Size Optional. A Long type variable. The size of the field.

Remarks

The Type determines the type of the value to be stored in the field. It can take one of the following values:
cdbBoolean - A boolean variable.
cdbByte - Integer (1 byte).
cdbInteger - Integer (2 bytes).
cdbLong - Integer (4 bytes).
cdbCurrency - Real (can support the currency symbol).
cdbSingle - Real.
cdbDouble - Double-precision real.
cdbDate - Date.
cdbBinary - Binary value.
cdbText - Text.
cdbLongBinary - Binary array.
cdbMemo - Binary array.
cdbGUID - Identifier (4 bytes).
cdbBigInt - Integer (8 bytes).
cdbVarBinary - Binary array.
cdbChar - Character (1 byte and 2 bytes if UNICODE).
cdbNumeric - Real number.
cdbDecimal - Real number.
cdbFloat - Real number.
cdbTime - Time.
cdbTimeStamp - Date and type.
Support for a type depends on the driver and the database.

The values specified in Type and Size are considered only when creating the table.

The created Field object needs to be added to the Fields collection by using the Append method.

For the Index and Relation objects the Name field must exist in the table, on which these objects are based.

Example

.......

 

See Also

Field Object, Fields Object, Index Object, Relation Object, TableDef Object, Name Property, Append Method.