RELATE ONE

4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next

version 3


RELATE ONE (manyTable | Field{; choiceField})

ParameterTypeDescription
manyTable | FieldTable | FieldTable for which to establish all automatic relations,
or Field with manual relation to one table
choiceFieldFieldChoice field from the one table

Description

RELATE ONE has two forms.

The first form, RELATE ONE(manyTable), establishes all automatic Many-to-One relations for manyTable in the current process. This means that for each field in manyTable that has an automatic Many-to-One relation, the command will select the related record in each related table. This changes the current record in the related tables for the process.

The second form, RELATE ONE(manyField{;choiceField}), looks for the record related to manyField. The relation does not need to be automatic. If it exists, RELATE ONE loads the related record into memory, making it the current record and current selection for its table.

The optional choiceField can be specified only if manyField is an Alpha field. The choiceField must be a field in the related table. The choiceField must be an Alpha, Numeric, Date, Time, or Boolean field; it cannot be a text, picture, BLOB, or subtable field.

If choiceField is specified and more than one record is found in the related table, RELATE ONE displays a selection list of records that match the value in manyField. In the list, the left column displays related field values, and the right column displays choiceField values.

More than one record may be found if manyField ends with the wildcard character (@). If there is only one match, the list does not appear. Specifying choiceField is the same as specifying a wildcard choice when establishing the table relation. For information about specifying a wildcard choice, refer to the 4th Dimension Design Reference.

RELATE ONE works with relations to subtables, but you must have a relation to the parent table and to the subtable's related field in order for the relation to be properly established. When using a relation to a subrecord, you must first use RELATE ONE to load the related record into memory, then use a second RELATE ONE command for the subtable.

Example

Let's say you have an [Invoice] table related to a [Customers] table with two non-automatic relations. One relation is from [Invoice]Bill to to [Customers]ID, and the other relation is from [Invoice]Ship to to [Customers]ID.

Since both relations are to the same table, [Customers], you cannot obtain the billing and shipment information at the same time. Therefore, displaying both addresses in a form should be performed using variables and calls to RELATE ONE. If the [Customers] fields were displayed instead, data from only one of the relations would be displayed.

The following two methods are the object methods for the [Invoice]Bill to and [Invoice]Ship to fields. They are executed when the fields are entered.

Here is the object method for the [Invoice]Bill to field:

   RELATE ONE ([Invoice]Bill to) 
   vAddress1 := [Customers]Address 
   vCity1 := [Customers]City 
   vState1 := [Customers]State 
   vZIP1 := [Customers]ZIP

Here is the object method for the [Invoice]Ship to field:

   RELATE ONE ([Invoice]Ship to) 
   vAddress2 := [Customers]Address 
   vCity2 := [Customers]City 
   vState2 := [Customers]State 
   vZIP2 := [Customers]ZIP

See Also

OLD RELATED ONE, RELATE MANY.


4D - Documentation   Français   English   German   4th Dimension 2004, Command Theme List   4th Dimension 2004, Command Alphabetical List   4th Dimension 2004, Constant Theme List   Back   Previous   Next