Brian Dunning's FileMaker Custom Functions

LastRepNumber ( repeatingField ; maxRepeat )

Returns the number of the last not empty repetition

  Average rating: 3.9 (44 votes) Log in to vote

Daniele Raybaudi   Daniele Raybaudi - Show more from this author

Share on Facebook Share on Twitter

  Sample input:
LastRepNumber ( repeatingField ; 10 )
  Sample output:
returns a value between 1 and 10 (or "" if repeatingField is empty)

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Returns the number of the last not empty repetition, much like Last(repeatingField) returns its contents.
Can be used with both 7 and 8 version of FileMaker, but is most useful with 8, where fields can be reached specifying the repetition number by a calculation.
For example, to set the next empty repetition to "whatYouWant" you can use:

Set Field [repeatingField [LastRepNumber ( repeatingField ; 10 ) +1];"whatYouWant"]
(where repeatingField has 10 rep).

This function comes in hand also if you want to clear all repetitions.
A simple loop:

Exit Loop if [LastRepNumber ( repeatingField ; 10 ) = ""]
Set Field [repeatingField [LastRepNumber ( repeatingField ; 10 )];""]
End Loop



Jim   Jim, NY
Mar 20, 2014
Does not work if the repeatingField is referencing another repeatingField that is a calculation.
This recursive function will return an incorrect number (always blank), since during the recursion, the repeatingField has not yet caluclated the result from the other repeatingField.

Only works with repeatingField that are not based on other calculations.

Log in to post comments.


Note: these functions are not guaranteed or supported by Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.