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?
I assume from your description that the delete button is outside the repeating subform? (I normally have a delete button in the subform that repeats so they can remove the instance they want)
If that is the case you can use something like this which removes the last instance.
Table1._Row1.removeInstance(Table1._Row1.count - 1);
Yes, it is outside of the repeating subform. Mainly because when I try to put it inside the subform it no longer even works. It may as well just be an image of a button.
This is what I currently have that is removing as it should if it weren't for the numbering: " Employment.EmpCont.instanceManager.removeInstance(1); "
My numbering script is: " this.rawValue=this.parent.instanceIndex +4 ". The 4 is because this is an appendix form basically and 1 to 3 are on the original (with no option to add).
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;
Employment._EmpCont.removeInstance(Employment._EmpCont.count - 1);
The code for a delete button within the repeating subform would be something like;
_EmpCont.removeInstance(_EmpCont.index + 1);
The first option worked! Thank you.
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.
For now it does the basics of what I wanted.
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.
But glad you can keep moving forward.