selectrecordsrelatedto
DATABASE
,
OPTION
,
VALUE

The selectrecordsrelatedto statement selects records in the current database that are related to any record in another database.


Parameters

This statement has three parameters:

database – name of the related database.

option – additional option, or dictionary containing options.

value – value of additional option.


Description

This statement selects records in the current database that are related to any record in another database. A prerequisite for using this statement is that you must use the Datbase Options>Relations dialog panel to set up a relational link from the current database to the second database. See Relational Database Management to learn how to set up these links.

Once the relations are set up, a simple one line program using the selectrecordsrelatedto statement can be used to select all records that are related. For example, suppose you have a vendor database and a checkbook database, linked by the vendor name. This program could be used in the Vendor database to select all vendors for which one or more checks have been written.

selectrecordsrelatedto "Checkbook"

If you want to select records that are NOT related to any records in the related database, use the REVERSE option, like this.

selectrecordsrelatedto "Checkbook","REVERSE","YES"

This example would select all vendors that haven’t had a single check paid to them.

Select Mode

The MODE option allows an alternate selection mode to be used. The available modes are:

For example, suppose you have a vendor database and a checkbook database, linked by the vendor name. This program could be used in the Vendor database to select all vendors for which one or more checks have been written. However, if none of the vendors have any checks written to them, the previous selection in the Vendor database will be retained.

selectrecordsrelatedto "Checkbook","MODE","safeselect"

Specifying Additional Relation Options

If needed, you can customize one or more relation options, overriding the options set up in the Database Options>Relations dialog. For example, this code will select only vendors that have been sent checks in the past 180 days.

selectrecordsrelatedto "Checkbook","SOURCESUBSET",{CheckDate > today()-180}

See the join statement to learn more about the relation options that are available. Please note that any additional options you specify must be in all upper case, with no additional spaces or punctuation.


See Also


History

VersionStatusNotes
10.2NewNew in this version.