2 Replies Latest reply on Oct 6, 2010 3:51 AM by LaRetta_1

    loop script delete records error 101

    AndrewFish

      Title

      loop script delete records error 101

      Post

      HI,

      I am trying to write a a script that deletes child records. The problem I'm having is that the loop exits after deleteing 2 records everytime regardless of how many records there are. The script debugger show error 101(record is missing)

      the script looks like this.

      show custom dialog (are you sure you want to delete customer and all associated students?

      if (get(lastmessagechoice)= 2)

      Go to related record (show only related records from Table "Students" Usiing layout Students Form"

      go to record/request/page [first]

        Loop

          delete record/request (no dialog)

          Go To Record [Next ; Exit after last]

        End Loop

      end if

      Any help would be appreciated

      Cheers!!

        • 1. Re: loop script delete records error 101
          philmodjunk

          Are you sure you have any related records to delete?

          this script does not check for whether there are any related records to delete so it could delete records from the completely wrong table.

          You should have If [ Not IsEmpty ( students::StudentID ) ]

          just before the Go TO related records step.

          Your loop is self destructing because delete record moves you to a different record and then go to Record [next] moves you to yet another record.

          Instead of a loop, just use this step: Delete All Records. It won't delete all records in your table--just those that the Go To Related Records step pulled up into a found set.

          • 2. Re: loop script delete records error 101
            LaRetta_1

            In addition, any time you loop and use 'Go To Record/Request Next [ Exit After Last ] it throws a 101 error because in the loop, when ready to exit, the 'next record is missing.'   

            If you happened to use generic test of If [ Get ( LastError ) ] to decide whether to proceed or exit, you might assume you have a REAL error because of it and exit your script when it isn't really a REAL error at all but normal behavior.