New Record missing data

What am I missing???  In FM8, I have 2 related tables in a single database.  I create a new record in the primary table and want to create an empty record in the related table but do want to insert the appropriate data in the field that is used to relate the two.  Of course I only want to create a new record in the related table if none exists.  My script is:

// I am in a layout for table "personal".  I commit the record I am entering.

Commit Records/Requests [ Skip data entry validation; No dialog ]

// Now I want to check to see if a related record exists, and if not create one.

Set Error Capture [On]
Go to Related Record [ From table: “Research”; Using layout: “ResearchTable” (Research) ][ Show only related records ]
If [ Get(LastError) <> 0 ]
   Go to Layout [ “ResearchTable” (Research) ]
   New Record/Request

// Here's where the problem arises.  A new blank record is created, but the personid field is never updated
// by the next statement.  I tried adding a go to field script step but that made no difference.

   Set Field [ Research::PersonID; Personal::PersonID ]
   Commit Records/Requests [ Skip data entry validation; No dialog ]
End If

I'm sure this is something trivial, but I can't figure it out.  Thanks for any help.
dspaceAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lesouefCommented:
Can't work: at the very moment where you set Research::PersonID, the relation does not exist yet, since research::PersonID is still empty, so you define this in the current record, god knows which one that is!

There are several ways to do this, the easiest for me is:

Set Error Capture [On]
Go to Related Record [ From table: “Research”; Using layout: “ResearchTable” (Research) ][ Show only related records ]
If [ Get(LastError) <> 0 ]
set variable $id = Personal::PersonID           <<<<<<<<<<<<< add on
   Go to Layout [ “ResearchTable” (Research) ]
   New Record/Request

// Here's where the problem arises.  A new blank record is created, but the personid field is never updated
// by the next statement.  I tried adding a go to field script step but that made no difference.

   Set Field [ Research::PersonID; $id ]  <<<<<<<<<<<<<<< modification
   Commit Records/Requests [ Skip data entry validation; No dialog ]
End If

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dspaceAuthor Commented:
Worked like a charm.  Thanks for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
FileMaker Pro

From novice to tech pro — start learning today.