3 Replies Latest reply on Sep 8, 2012 7:00 AM by BobO'Neal

    How to continue after FIND function fails?

    BobO'Neal

      Title

      How to continue after FIND function fails?

      Post

      I have a script that performs multiple Record FINDs & prints on multiple layouts. When there are no Records that match one of the FIND criterias, the script stops at that point & I get the notice of no Record matches. It gives me the manual choice to Cancel, Continue or Modify Find.

      How can I make the script continue automatically to the end without having to manually click on the Continue? 

        • 1. Re: How to continue after FIND function fails?
          schamblee

          Example Script

           

          Set Error Capture[on]

          Perform Find[Restore]

          If [Get(LastError)>0]

          Enter Browse Mode[]

          Endif

           

          You May want a message of some kind to let the user know that no records were found before you Enter Browse Mode[]

          • 2. Re: How to continue after FIND function fails?
            Sorbsbuster

                 Alternatively, I usually:

                 Freeze window
                 #
                 Set Error Capture [On]
                 Allow User Abort [Off]
                 #
                 Go to layout [for first find]
                 Enter Find Mode[]
                 Set Field [set the first field of the find criteria.  Add more of this step as you need]
                 Perform Find
                 If [ Get (FoundCount ) = 0]
                    Show all records
                 Else
                    Do print set up, sort, Print, etc
                 End If
                 #
                 Go to layout [for second find]
                 Enter Find Mode[]
                 Set Field [set the first field of the find criteria.  Add more of this step as you need]
                 Perform Find
                 If [ Get (FoundCount ) = 0]
                    Show all records
                 Else
                    Do print set up, sort, Print, etc
                 End If
                 #
                 #repeat that module as often as you need
                 #
                 Go to layout [Original layout]

                 You can also print 'silently' to avoid the user having to click 'Print' several times.  But then they can't opt to change printer each time.  Over to you which is easier for the user.

            • 3. Re: How to continue after FIND function fails?
              BobO'Neal

                   Thanks to both of you for the response. I was forgetting about the "Set Error Capture on". It works great now. I used some of the code in Sorbsbuster's response also to skip the print on the blank Finds.

                   Great to have expert help when I get stuck. Thanks.