Find empty repetition?
I have a field with 4 repetitions. Is it possible to find records with, say, an empty 3rd repetition?
http://buzz.beezwax.net/2011/10/29/working-with-repeating-fieldsWorking with Repeating Fields
http://www.briandunning.com/cf/450FirstBlankRepetition ( RepeatingField ; StartingRepetition )
Locating the first empty repetition of a repeating field can help when trying to add to a list of items. For instance, you might want to keep a history of modification dates.
Before entering the script below you will need to create the following field:
Counter (global number field)
Go to Field ["Repeating field"]
Set Field ["Counter", "0"]
Set Field ["Counter", "Counter + 1"]
Exit Loop If ["IsEmpty(GetRepetition(Repeating Field, Counter))"]
Go to Next Field
If you want to paste something into the last repetition then just add a script command at the very end (outside the loop) to Paste from the clipboard or Paste Special.
In order for the scripts to work you will need to have all the repetitions in the repeating field follow each other in the tab order. If you have not altered the tab order, then this will already be the case.
FileMaker Pro searches for values in all repetitions, even those that aren't visible in the current layout., so it is not possible to find records with a particularly empty repetition.
DavidAnders, your script above has an error (Go to Next Field inside the loop)
a more modern apprach is:
Set Variable[$counter; Value:0]
Set Variable[$counter; Value:$counter + 1]
Exit Loop If[IsEmpty ( YourTable::RepeatingField [ $counter ] )]
While there are exceptions, almost always a related table of individual records makes for a better option to use than a repeating field.
There are always tricks to use repeating fields and find the 3rd [appearing empty to user] repeating field, using FMP Find
The view may not be worth the climb.
@Phil I have always been curious which would be faster in a bench mark test, using an indexed repeating field in a loop or indexed records in a loop. I am slowly programming shuffling a deck of cards using both methods.
if you find out, let me know. I'd be curious too, but generally find that the limitations inherent to repeating fields pretty much dictates that a related table will be the better option just due to the lax of flexibilty.
Thanks for your answers! I'll have to come up with a different solution I guess.
Retrieving data ...