ForeignTable Property

   

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

Syntax

VOIDSetForeignTable(LPCTSTR pstr );

CStringGetForeignTable(VOID);

Parameters

Type Argument Description
LPCTSTR pstr A pointer to a string that contains the name of the foreign table.

Remarks

The ForeignTable property setting of a CdbRelation object is the Name property setting of the CdbTableDef or CdbQueryDef object that represents the foreign table or query; the Table property setting is the Name property setting of the CdbTableDef or CdbQueryDef 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 already have to 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 CdbRelation object to dbRelationDontEnforce, a trappable error would occur.

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

The following illustration depicts the relation described above.

This property is read/write for a new CdbRelation object not yet appended to a collection and read-only for an existing CdbRelation object in the Relations collection.