"Exit Loop If [ GetAsNumber ( $RemNum ) > GetAsNumber ( $MaxRep ) ]" I don't see the context of $RemNum. Is that a typo here, or in your script, or is it called somewhere else?
Hmmm, your script assumes that there are no empty repetitions between non-empty repetitions. Not the reason here, but something you may want to keep in mind.
I do see an error that would explain the problem, but could be just an error made here instead of an error in the original script:
You are counting reps with a variable named: $RepNum
But your are testing a variable named: $RemNum in your Exit Loop If step.
PS. There's a good chance that you can eliminate your repeating field by replacing it with a table of related recrods--which would eliminate the need to count repetitions.
Well I'm embarrassed for not catching that. Thank you very much. It was indeed a typo. My eyes were hurting from staring at this for hours just completely missing that I typed it in wrong. Thank you both.
I couldn't quite come up with logic on checking to first see if the repetition field was empty first. My Exit Loop If condition should handle that (though not the most gracefully). Is there a better way to check first to see if a repetition field is empty? Does the "Not IsEmpty" syntax work? Thank you again for catching that typo.
I still recommend against using a repeating field for this in the first place...
To modify your script, use two variables where you have one. Use one as you do now, but use a second one, incremented inside the If EndIf block to count the actual number of non blank values found and processed.
Check this second variable to determine when to exit the loop.
Excellent. I'll take a look at changing it to a relational table setup because yes you are absolutely correct. This was an inherrited database so I was just working with what I had at the time. When I have a chance I will definitely create a new table for these repetition fields. Thanks again.