2 Replies Latest reply on Jun 3, 2009 8:55 AM by mrvodka

    A script with find that does not stop when it does not find the record

    annacaltech

      Title

      A script with find that does not stop when it does not find the record

      Post

      Hi,

       

      I am setting up a script (for a button) that should take my field content from the first layout and go to a second table and search if it has related records there. If so, it should take another fields content from the second table and paste that in in a field in the first layout. I have gotten this to work as long as the record has a related record in the second table. But as not all records in the first layout has related records in the second table I get trouble when I try to run the script for them to. If I do, a window comes up saying that no records were found and asks if I want to modify the search. How do I turn that off? Meaning if it does not find a related record it should just "do nothing". 

       

      Thanks,

      anna 

        • 1. Re: A script with find that does not stop when it does not find the record
          craig5005
            

          In the script, turn on error capture.

          Then have a line that reads something like;

          If get(lasterror) = 401

          show custome dialogue "blah blah blah"

          or you can set it to go to original layout, or whatever you want.

           

          That way, if the error occurs, it will do what you tell it to instead of bringing up that error message you mentioned.

           

          The 401 may not be the correct error code, but if you just search in the help, it will bring up a list of error codes, just find the appropriate one.

           

          Craig

           

          • 2. Re: A script with find that does not stop when it does not find the record
            mrvodka
              

            You need to capture first if there are related records. You can do this by using Set Error Capture [On] in conjunction with Get ( LastError ) or if checking for related records from A parent record you can use something like.

             

            If [ not IsEmpty ( child::pkChildID ) ] or just - child::pkChildID coudl be used in this case.

            Go to Related Records

            End If

             

            It checks to see if the first related record's primary key is there. If there are no child records then obviously it wouldnt be there.