InfoPath – Limit a Repeating Section

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/

https://alecpojidaev.wordpress.com/2010/01/07/accessing-previous-rows-in-repeating-group-for-browser-enabled-forms/

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.

  1. Create a new interger field and add to your repeating group.  For this example, we will name it Count
  2. Right click on Count and click properties, then click the fx button.
  3. Check the box to Edit XPath (advanced) and enter in the following formula: count(../preceding-sibling::*) + 1
  4. Click Verify Formula then click OK
  5. Make sure ‘Refresh value when formula is recalculated’ is checked
  6. Click OK
  7. If you have not added the repeating section to your form, do this now
  8. Preview your form to make sure that everything is working properly
  9. Click on the repeating section and then click ‘Manage Rules’ in the ribbon
  10. Add the following formatting rule
    1. For the Condition:
      1. Field: Count
      2. is greater than or equal to 5
    2. Check ‘Don’t allow users to insert or delete this control’
  11. 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.

LimitRepeatingSection

Enjoy and Stay Salty!

 

InfoPath – Multiple attachments in one web based form

Attachments in InfoPath are great.  The only issue with this, is that you can only attach one file to your form at a time.  In order to get a around this, you will need to add a handy dandy repeating section.  I have also added a count box to show how many attachments have been added to your form.  You also will have the ability to hide all of your attachments.  That’s where the count comes in handy.

I like to use this hide function for my attachments especially when I have a form that goes through an approval process.  I have attached a starter form using these controls.  The ‘attCount’ field has a default value set to count how many controls have been added to your form.  There is one rule set for the repeating section to hide it the ‘hideAttachments’ is set to ‘TRUE’.

I saved the form in a 2007 web based format.  You should be able to open in all versions of InfoPath 2007 – 2013.

Download Multiple Attachments Form

Stay Salty!