There are times when you have a repeater but you do not want the user to be able to add more than a certain number of instances of the repeater in the interview.
You could use a Rule command, but then the user will only get the message once they have pressed the “OK”, or “Assemble” button.
The command
«
MaximumRepeats(Child,3)
»
would prevent the user from entering more than 3 Child instances in the interview.
The command is very flexible, and supports a function or data element in the second argument. This makes it possible to have a different MaximumRepeats for different situations.
For example, you could say that if there is no Parent value, then the number of children should be zero, otherwise the maximum should be 2, like this:
«
MaximumRepeats(Child,IIf((Parent = ''),0,2))
»
For completeness sake – the Required command will ensure that at least one Child is entered, if that’s what is needed:
«
Required(Child)
»«MaximumRepeats(Child,3)
»
This would ensure that at least one but at most 3 Child elements would be input in the interview.