Variable not passed to subform record after the 6th record is added.

Variable not passed to subform record after the 6th record is added.

I have a subform that receives a value "Country" from a selection in the Parent form, when a record is added to the subform.

The following script works up to the 6th record then fails every time on the 7th and stops the form from being submitted with an error. 

The attached screen shots are from the same page but it was too long so I had to capture into several consecutive images. There was a 4th image but just found that 3 attachments are max.

*************
Code to pass Country to Subform record: 

row.Country = input.Country;
churchlist  =  Churches  [Country == input.Country];
clear row.Church;
row.Church:ui.append(churchlist.Church.getall());