Simple form with one subform repeating. Subform contains an increasing index number with each instance. Add button works as anticipated. Remove button removes the first instance added rather than the last instance added and subsequently the index numbers are out of order.
Is the problem with remove button or the "instanceIndex" code?
Every now and then I end up with a button that doesn't click, usually it's because I've typed something into the calculate event instead of the click event and it's become "readonly", but there must be other ways as well. Check in the XML Source if the button has a access="readOnly" attribute and delete it.
I tried again to move the button(s) into the subform so that a particular row could be added/deleted in a particular spot as needed, though, it still treats them as if they were just a picture of a button.
The "1" in your code refers to the instance number, which is why it is deleting the first row. You'll have to change the code I gave to match the names of the elements in your form, so it will be more like;