KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to not add records to a subtable in a loop
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: September 19, 2007

A button to that is used add a record to a subtable using the Standard Action "Add Subrecord" always adds records in a loop. Unlike regular tables and forms, in which you can change the action related to the Validate button of the Input Form, in subtables this does not functionally fix this problem.

To make a button that lets the user create new records in a Subtable without adding the records in a loop, do not use the Standard Action "Add Subrecord". Instead clear the Standard Action for the button and include the following code:

` Method: createrecord_subtable1
CREATE SUBRECORD([Table 1]Subtable1)
MODIFY SUBRECORD([Table 1]Subtable1;"Input")

Of course, the code above is generic and table names, subtable names, and form names must be adjusted accordingly.

When using this technique it is also advisable to disable the Double Click on Empty Line Object Property of the subtable. Simply select that property from the list and change the value from Add Record to Do Nothing.

For more documentation dealing with subrecords follow this link:

http://www.4d.com/docs/V6U/V6U00051.HTM