CreateRelation Method

Creates a new Relation object.

Applies to objects: Database

Syntax

[[Set] RetVal = ] object.CreateRelation([Name], [PrimaryTableName], [ForeignTableName])

The CreateRelation method syntax has these parts:

Part Description
object Required. A reference to an instance of the object.
RetVal Optional. A Relation type variable.
Name Optional. A String type variable. The name of the relation, being created.
PrimaryTableName Optional. A String type variable. The name of the referenced table, that contains the primary key.
ForeignTableName Optional. A String type variable. The name of the referenced table, in which the external key will be created.

Remarks

Once a new Relation object has been created, you need to set the fields of the PrimaryTableName table, on which it will be based. For each such field you need to call the CreateField method with its name, set the ForeignName property to it and add the created object to the Fields collection by using the Append method.

The relation itself will be created in the database on calling the Append method of the Relations collection.

Example

.......

 

See Also

Database Object, Fields Object, Relation Object, Relations Object, ForeignTable Property, Name Property, Table Property, Append Method, CreateField Method.