# Name & Parameters: LastRepNumber ( repeatingField ; maxRepeat ) Description: Returns the number of the last not empty repetition, much like Last(repeatingField) returns its contents. Can be

This topic is 5695 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

Name & Parameters: [color:red][big] LastRepNumber ( repeatingField ; maxRepeat ) [/big]

Description: 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:

Loop

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

Set Field [repeatingField [LastRepNumber ( repeatingField ; 10 )];""]

End Loop

Sample Input:

LastRepNumber ( repeatingField ; 10 )

Results:

returns a number between 1 and 10 ( or "" if repeatingField is empty )

Recursive: yes

Formula:

```/*

LastRepNumber custom function

Author

Daniele Raybaudi

Type

Recursive

Format

LastRepNumber ( repeatingField ; maxRepeat )

Parameters

repeatingField - any repeating field, or an expression that returns a reference to a repeating field.

maxRepeat - the number of repetitions assigned to repeatingField

Data type returned

number

Description

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:

Loop

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

Set Field [repeatingField [LastRepNumber ( repeatingField ; 10 )];""]

End Loop

April 27, 2006

*/

Case (

IsEmpty ( Last ( repeatingField ) ) ; "" ;

Last ( repeatingField )  = GetRepetition ( repeatingField ; maxRepeat )  ; maxRepeat ;

LastRepNumber ( repeatingField ; maxRepeat - 1)

) ```

Required Functions:

Author(s) raybaudi

Date: 04/27/06

Credits:

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

LastRepNumber.zip

##### Share on other sites

This topic is 5695 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account