4 Replies Latest reply on Oct 2, 2009 12:17 PM by Ringger

    How do you continue a script when "No records match this request" appears?

    Ringger

      Title

      How do you continue a script when "No records match this request" appears?

      Post

      I run FMP 10.vs, windows 2007 and have created a script to run 4 other scripts, create a PDG (append) and send e-mail. The problem sometimes 1 of the 4 sub-scripts cannot find recrods so "no records match this request" appears. You then have to click modify find, continue or cancel. Is there a way to continue the script without hitting the continue button? I have already read the "Working Around the "no records match this request" message in the script maker section of this website and that will not work for me. Suggestions?

        • 1. Re: How do you continue a script when "No records match this request" appears?
          ninja
            

          Howdy Ringger,

           

          If you set Error Capture [On] just prior to the "Perform Find", the script won't stop and you wont get the popup window.

           

          Immediately after the find, you can put in:

           

          If (Get(FoundCount) = 0)

               Do the thing if there are no found records

          EndIf

           

          Then your script will run past the "no found records" event without interaction needed.

          If you want to end the script if no records are found, make sure you put an "Exit Script" or "End Script" in the If statement.

           

          Is this what you're looking for?

           

          Edit: If there is a reason to flag errors further down the script, make sure to turn ErrorCapture back on... ;)

          • 2. Re: How do you continue a script when "No records match this request" appears?
            Ringger
              

            Do I need to put the set error capture and if/end if in each of the 4 sub-scripts, just one of them or the 1 script that combines the 4 sub-scripts. Also, I'm using a Constrain Found Set..does the error capture go be for the perform find and It/end it after the Constrain Found Set?

             

            • 3. Re: How do you continue a script when "No records match this request" appears?
              ninja
                

              Howdy Ringger,

               

              I don't know enough about the rest of your script/subscipts to answer the question directly, but perhaps looking at the concept here will let you answer your own question.

               

              The pop-up window is telling you about an error.

              If you don't want it to appear, you capture the error (Set ErrorCapture [On])

              The error, if there is one, means something...and the error in a find is typically that it didn't find anything.

              If you want to have something done when there are no found records, that's what the If...EndIf is for.

              If you don't care to do anything if no records are found, leave the If...EndIf  out altogether.

               

              The Errorcapture should be used whenever you want the window to NOT appear when no records are found.  If you do finds in each subscript, you should think about what you would like to have happen (A) if there are records found, and (B) if there aren't any found.  The IF...EndIf is your tool to do different things based on whether or not records were found.

               

              Situation: If you want to change data in the found records, and there are none found, you'll then end up changing data in records you didn't mean to...therefore if FoundCount=0, exit the script before the data change happens.

               

              Situation: if you are just constraining the found set according to multiple criteria, and no records are found...just capture the error so the window doesn't pop up and leave the If...EndIf out altogether.

               

              At the end of the day, this is a tool.  Consider what your script is doing, and where this tool would be appropriate to accomplish your end goal.  It will be appropriate in some situations, and inappropriate in others.  Simply supressing the "No Records Match..." dialog can be dangerous (see Situation #1), so make sure you consider the downstream consequences and change course using the If...EndIf as needed.

               

              More than I intended to write, but I figured that understanding was equally important to having the solution.

              • 4. Re: How do you continue a script when "No records match this request" appears?
                Ringger
                  

                Ninja - you're a life saver and works perfect.

                Thanks - Ringger