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 – Add Sequential Dates

In the past, I needed to add a date sequentially on insert of a repeating table.

I found a post by S.Y.M Wong-A-Ton that helped me achieve this.  Here is a link to that post: http://www.bizsupportonline.net/infopath2007/automatically-populate-repeating-table-infopath-sequential-dates.htm

If you are working on anything InfoPath, this site is a GREAT resource.  I highly suggest that you check it out.

I have included a sample form for you to download.  You can add this control to any of your existing forms.  Here are the steps for re-creating this from scratch

  1. Add a group
  2. Add a repeating group
  3. Add two fields:  date picker and text fieldField 1 (date picker control)
    Field 2 (text control)
  4. Right click on field2 and insert the following statement in the value box
    preceding-sibling::group2[1]/field1

Make sure to change the field names if different than the ones in your form.

Here is the form you can download by clicking.  AddSequentialDates