Create a One-To-Many Data Entry Form Sample
File: ...\Samples\Solution\Forms\Many.scx
This sample illustrates the basic tasks associated with a one-to-many data entry form.
When you choose the New button beside the parent table text boxes, the following code is executed:
SELECT CUSTOMER
APPEND BLANK
THISFORM.Refresh
When you choose the New button beside the grid that displays the child records, more code is executed.
After selecting the orders table, the code calculates a new id value for the order, adds the blank record, then stores the parent id and order id to the appropriate fields.
CALCULATE MAX(order_id) ALL TO lMaxID
lMaxID = ALLTRIM(STR(VAL(lMaxID) + 1))
APPEND BLANK
REPLACE cust_id WITH Customer.Cust_id IN orders
REPLACE order_id with lMaxID in orders
Note
This method of creating a new id value would not be reliable if multiple users were adding new orders at the same time. Instead, you can create a new id as illustrated in the Create a Default Unique ID Value for a Field sample.
See Also
Tasks
Create a Single Table Data Entry Form Sample
Create a Default Unique ID Value for a Field Sample