6 Replies Latest reply on Feb 19, 2013 3:11 PM by JSO

    Find empty repetition?

    JSO

      Title

      Find empty repetition?

      Post

           I have a field with 4 repetitions. Is it possible to find records with, say, an empty 3rd repetition?

        • 1. Re: Find empty repetition?
          davidanders

          http://buzz.beezwax.net/2011/10/29/working-with-repeating-fields
          Working with Repeating Fields

          http://www.briandunning.com/cf/450
          FirstBlankRepetition ( RepeatingField ; StartingRepetition )

          http://help.filemaker.com/app/answers/detail/a_id/3209/~/scripting-the-placement-of-the-cursor-into-the-first-empty-repetition

               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"]
               Loop
               Set Field ["Counter", "Counter + 1"]
               Exit Loop If ["IsEmpty(GetRepetition(Repeating Field, Counter))"]
               Go to Next Field
               End Loop

               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.

          • 2. Re: Find empty repetition?
            gcatnine

                 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]
                 Loop
                 Set Variable[$counter; Value:$counter + 1]
                 Exit Loop If[IsEmpty ( YourTable::RepeatingField [ $counter ] )]
                 End Loop

            • 3. Re: Find empty repetition?
              philmodjunk

                   While there are exceptions, almost always a related table of individual records makes for a better option to use than a repeating field.

              • 4. Re: Find empty repetition?
                JimMac

                     There are always tricks to use repeating fields and find the 3rd [appearing empty to user] repeating field, using FMP Find

                     But...

                     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.

                     Jim...

                • 5. Re: Find empty repetition?
                  philmodjunk

                       @Jim

                       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.

                  • 6. Re: Find empty repetition?
                    JSO

                         Thanks for your answers! I'll have to come up with a different solution I guess.