Let’s say you have just added a repeating table to your InfoPath form and you want the first column (textbox) to have numbering applied automatically.
All you need to do is to right click on the textbox and choose its properties. At this point, you will need to know two things:
In the Default Value area, click on the ‘fx’ button (function). The ‘Insert formula’ dialog will pop up. In the formula textbox, enter this formula:
count(preceding-sibling::GroupName/FieldName) + 1
Naturally, you’ll supply your own Group Name and Textbox (field) name in the function. If you also click on the checkbox ‘Refresh value when formula is recalculated’, an added plus, is that, doing it this way, if you decide to remove a row from the repeating table, this will automatically adjust the numbering for you.
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF