You need a loop to go through the instances to find the one you want.
I've uploaded a quick sample here:
https://acrobat.com/#d=HCE5l51RbmjfxSkjGIZbDA
I've just done one subform (subHolder) with a repeating subform inside it (subRepeat). It presents multiples of a repeating subform with the index displayed and a textfield that you can type into, if the value of the textfield is "text" it will remove that subform when you click off the checkbox.
var vInstances = this.resolveNodes("subHolder.subRepeat[*]");
if (this.rawValue == 1){
subHolder._subRepeat.addInstance(1);
}
else{
for (i = 0; i < vInstances.length; i++) {
if (vInstances.item(i).TextField2.rawValue == "text"){
vInstances.item(i).instanceManager.removeInstance(i);
}
}
}
You can shorten your add routine by using addInstance() instead of insertInstance() + moveInstance() - addInstance() puts the object at the end.
The underscore before the repeating object is a shortcut to the instanceManager.