I had a requirement in one of my forms to limit the number of repeating sections to be displayed.
I read through some blogs that gave me some ideas on how to increment the row number which was very helpful and got me on the right track. Check them out when you have a moment:
http://nickhurstblog.com/2011/08/26/infopath-2010-repeating-table-incremental-row-number/
Basically, you will need to auto increment a number field when a new section is added to the form. There is a very simple way to handle this and it only takes one rule and one field. To do this, follow these steps.
- Create a new interger field and add to your repeating group. For this example, we will name it Count
- Right click on Count and click properties, then click the
button.
- Check the box to Edit XPath (advanced) and enter in the following formula: count(../preceding-sibling::*) + 1
- Click Verify Formula then click OK
- Make sure ‘Refresh value when formula is recalculated’ is checked
- Click OK
- If you have not added the repeating section to your form, do this now
- Preview your form to make sure that everything is working properly
- Click on the repeating section and then click ‘Manage Rules’ in the ribbon
- Add the following formatting rule
- For the Condition:
- Field: Count
- is greater than or equal to 5
- Check ‘Don’t allow users to insert or delete this control’
- For the Condition:
- Preview your form
You should now see that you can only be able to add a total of five repeating sections. You can change this number to limit what you actually need.
I have included an example template that demonstrates how this works. Please note that this form was created in InfoPath 2013 and is a browser based form.
Enjoy and Stay Salty!