The second line of this script should be
Go to field[Model::Facotry]
If I want to add new model or new factory to Model table, I want FC table to be updated simultaneously.
Shouldn't this say: "If I want to add new model from a new factory to Model table, I want FC table to be updated simultaneously." ?
If so and assuming that "Factory" is an auto-entered serial number, then your script would be:
#Script is performed from layout based on Model
Go to Layout [ Fc (FC) ]
Set Variable [$Factory ; FC::Factory]
#You may want to pause or halt the script here so that you can enter more info about the new factory Or see note below this script
Go to Layout [Original Layout]
Set Field [Model::Factory ; $Factory]
Note that if you add fields from FC to your Model layout, you can enter information for your new Factory record directly on the Model layout after performing this script.
I may add a whole new facotry with a new model to Model table
or just add a new model to an existing facotry.
Either situation can happen.
Yes, but you only need a new record in Factory when the factory is new.
When you need to add a model for an existing factory, you only create a new model in the model table and link it to Factory by entering or selecting a value in the Model::Factory field. This may not need any script at all.
You are right Phil, having two buttons will make things clear and easier.
I still did not get Set Variable sentence you reversed above. What I had in mind was reading the new facotry added to Model table, and attach value to $Factory, then auto-enter Factory field in Facotry table.
Why you wrote as : Set Variable [$Factory ; FC::Factory]?
And if I halt the script, will it read till I actually type in in Model table?
I'm assuming that Factory is an auto-entered serial number. (If not it should be).
Thus creating a new record in FC automatically enters a value into FC::Factory.
This value must then be copied to the new Model::Factory field in order to link the two new records to each other.
If you are linking by factory name, this script won't work as written, but you'd still need to enter a factory name in the new Factory table before you can copy it to the match field in Model.
Matching by factory name creates issues you can avoid by using the serial number. Factory names may not be unique, they can change and users can enter the names incorrectly. Any of those situations can result in having to change the value of FC::Factory, but doing so breaks the link to any related records that link by the original value. This complication and potential for serious problems with your data is avoided when you use a serial number field instead of a name in your relationships.