I am running FM 5.5.
I had problems with all three of your suggestions.
1. A script in the child table will create a new record but it needs the key value which can only be passed into a Global variable from the parent script. Then issuing another SetField() from the parent script will write over the current record in the child. If there is more than one record with the same key, the parent will then always replace the first record. I could not find anyway to step through the child records to the one I want.

2. Cannot import from the parent. Remember that there is a relation between the parent and the child. If I am in the child, I would need a relation back to the parent in order to see any fields in the parent. This gave me lots of trouble actually trying to make it work so I gave up.

3. The portal technique was a mess. I couldn't get it to show more than one child record in the parent window.

After a lot of hassle I finally got something working. From the parent I used SetField() for each field in the child record to create a new record. Then I used the External option to run a child script that saved the key field, put a 9999999 in the key field, then issued New to create a new record and put the original key in it. Then going back to the parent, I issued SetField() which wrote over the new record. This sequence was repeated for each child record of the same parent key.

After each set of child records for the current parent, I issued another child script that replaced all the 9999999 values with the saved key.

This is a real mess. It just wouldn't be practical for an application that is writing lots of child records on a random basis.


----- Original Message ----- From: "Geoff Graham" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Saturday, January 19, 2008 5:19 PM
Subject: Re: Adding records to a related file


On Jan 19, 2008, at 4:07 PM, Nicholas Geti wrote:

How do I add additional records to a child (related) table from a master table. These tables are related on the Invoice Number field in each table and I can add one record just by doing SetField() on the child's invoice field but if I issue the command again it simply writes over the previous one as expected. How do I force creating a second record having the same invoice number?

Use a script in the child table to make new records;
Use a script in the child table to import from the parent;
or, have a portal in the parent table to the child table that allows creating records, go to the last portal row, then create your child record by doing the SetField().

Those are 3 ways off the top of my head.

geoff

Reply via email to