Perhaps instead of a script, you should just enable the looked up value field option on this field. That option will automatically copy the data every time your ID field is updated.
Phil, I thought about using a look-up, but worried about all the records being updated every time my client makes a change, which is not desirable. Can I write a script that will perform a 'look-up only for the current record?
That's exactly what this feature does. A looked up value will be copied from the related table only when an update is performed on the key field in the current file.
Classic example of this is an invoice system where you can use looked up values to copy using prices fro a products table. If you enter or change the product ID in the current table, the matching unit price is copied. If you edit other fields and or records, the value does not change.
Phil, Thank you for the explanation. The reason for my confusion stems my having set fields as look-up fields and when a record was updated, I believe the other records in the table were updated. Or, do I have this understanding incorrect?
There's more than one kind of "lookup" you can devise for a filemaker database. That's why I've been careful to refer to a "looked up value field option".
What I am referring to works like this:
Define field in the main table where you will store the looked up value.
Define a relationship linking the main table to the look up table.
Double click the field definition in the main table to bring up field options.
Click the auto-enter tab.
Click the looked up value check box, specify the table occurrence name of the lookup table and select the field storing the value you want to copy over.
If you modify the key field in the main table, only the current record's lookup field will copy the related value. All other records remain unchanged. If you modify data in the look up table, data stored in the main table's fields will not be modified unless you either update the main table's key field or put the cursor in this field and select "Relookup".