Quote:from reading the example on page 248 I am only more confused. Why get the name from the subrecord if you are going to change it?
I think you must be refering to page 249? That example is just showing you that you can, both, read from
and post to the subform records. You don't normally do both at the same time, unless you need to check an existing value before you post, or if you want to document what the value was before changing it.
If you want to post a value, you would use FormFieldValue, as opposed to
@FormFieldValue.
Using the following example, if you want to post from the main form to the subform...
FormName would be the name of your subform,
Name would be the name of the element in the subform that you want to change,
Instance would be the result set number, or line item number in a table view subform, of the record you want to change,
NewVal would be the new value you want to send there.
FormFieldValue(FormName, Name, Instance, NewVal)So, you would use something like this to post to the 1st subrecord:
FormFieldValue("Tech Info", "Info", 1, Company_Name)If you wanted to get that info into the 2nd subrecord, you would simply change the 1 to a 2 (no quotes).
If you wanted to get that info into every subrecord, you would need to put this in a loop, and use a variable that increments with each pass, as the Instance parameter. Something like this:
For i = 1 to @FormResultSetTotal("Tech Info")
FormFieldValue("Tech Info", "Info", i, Company_Name)
NextOne of the ways to post to only a specific subrecord, is to also use @FormFieldValue in the loop. This allows you to read what is contained in one of the other elements to help determine if the current instance is the subrecord that you want to post to. The following example will only post Company_Name to subrecords where Info is blank.
For i = 1 to @FormResultSetTotal("Tech Info")
If @FormFieldValue("Tech Info", "Info", i) = ""
FormFieldValue("Tech Info", "Info", i, Company_Name)
NextAnd, of course, you can use multiple @FormFieldValue calls in the If-Then statement get more control over which subrecords are affected.