addrelatedrecord
DATABASE
,
OPTION
,
VALUE

The addrelatedrecord statement adds a new record to the related database corresponding to the current 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 adds a new record to a related database. The new record is linked to the current record in the current database. A prerequisite for using this statement is that you must set up relational links in both directions between the databases, using the Database Options>Relations dialog panel. 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 addrelatedrecord statement can be used to create a new database record in the related database. The new record will have the same key value as the current record, as shown in this diagram.

The new record will also contain any source data fields specified in the relation.

Specifying the Form or Window in the Related Database

If there is currently more than one window open associated with the related database, the addrelatedrecord statement will normally bring forward the topmost window associated with that database. If you wish, you can specify a specific form or window to bring forward.

To bring forward a specific form, use the "FORM" option. This example code will bring forward the Check form. If that form isn’t already open, it will be opened.

addrelatedrecord "Checkbook","FORM","Check"

To bring forward the data sheet, use the "DATASHEET" option, like this. If the data sheet isn’t already open, it will be opened for you.

addrelatedrecord "Checkbook","DATASHEET","YES"

To bring forward a specific window, use the "WINDOW" option, like this. The specified window must already be open. You can specify the window by name, or by number (see Window ID Numbers).

addrelatedrecord "Checkbook","WINDOW","Checkbook:Report"

See Also


History

VersionStatusNotes
10.2NewNew in this version.