ForeignTable Property

Applies To   Relation object.

Description

Sets or returns the name of the foreign table in a relationship (Microsoft Jet workspaces only).

Settings and Return Values

The setting or return value is a String data type that evaluates to the name of a table in the Database object's TableDefs collection. This property is read/write for a new Relation object not yet appended to a collection and read-only for an existing Relation object in the Relations collection.

Remarks

The ForeignTable property setting of a Relation object is the Name property setting of the TableDef or QueryDef object that represents the foreign table or query; the Table property setting is the Name property setting of the TableDef or QueryDef object that represents the primary table or query.

For example, if you had a list of valid part codes (in a field named PartNo) stored in a ValidParts table, you could establish a relationship with an OrderItem table such that if a part code were entered into the OrderItem table, it would have to already be in the ValidParts table. If the part code didn't exist in the ValidParts table and you had not set the Attributes property of the Relation object to dbRelationDontEnforce, a trappable error would occur.

In this case, the ValidParts table is the primary table, so the Table property of the Relation object would be set to ValidParts and the ForeignTable property of the Relation object would be set to OrderItem. The Name and ForeignName properties of the Field object in the Relation object's Fields collection would be set to PartNo.

See Also   ForeignName property, Name property, Table property, TableDef object.

Example

See the ForeignName property example.

Example (Microsoft Access)

See the ForeignName property example (Microsoft Access).