EPUB | CHM | PDF

TPSQLTable.Properties.MasterSource

Top Previous Next

Specifies the name of the data source for a dataset to use as a master table in establishing a detail-master relationship between this table and another one.

Syntax:

property MasterSource: TDataSource;

Description:

Use MasterSource to specify the name of the data source component whose DataSet property identifies a dataset to use as a master table in establishing a detail-master relationship between this table and another one.

At design time choose an available data source from the MasterSource property's drop-down list in the Object Inspector.

After setting the MasterSource property, specify which fields to use in the master table by setting the MasterFields property. At runtime each time the current record in the master table changes, the new values in those fields are used to select corresponding records in this table for display.

At design time, use the Field Link designer to establish the master-detail relationship between two tables.

Example:

Suppose you have a master table named Customer that contains a CustNo field, and you also have a detail table named Orders that also has a CustNo field. To display only those records in Orders that have the same CustNo value as the current record in Customer, write this code:

Orders.MasterSource := 'CustSource';
Orders.MasterFields := 'CustNo';

If you want to display only the records in the detail table that match more than one field value in the master table, specify each field and separate them with a semicolon.

Orders.MasterFields := 'CustNo;SaleDate';

See also: Example: MasterSource,MasterFields