2 Replies Latest reply on Mar 10, 2014 1:25 AM by lijnbach

    Behavior GTRR if number of records is 0

    lijnbach

      Title

      Behavior GTRR if number of records is 0

      Post

           I use GTRR, and everything is working fine, until the number of related records is zero.

           With GTRR I open a new window with a new layout. After this I perform a few extra script steps. (Extra find function, resize window, disable menu etc.). This works all fine, until the number of records is zero. Then the window and the lay out (for the related records) immediately closes, without a warning. (Or even doesn't come up).

           But, after closing the window and the related lay out, the script steps are going on. So I get a window resize of my main window and the find function is going on.

           I also build a extra script step, directly after the GTRR step, where If [ Get (CountFound) = 0] / Open Dialog; "No records found". But even this script step goes on, on the original main lay out.

           Is there a way to avoid closing down the window and the lay out for the related records if number of records is zero? Or do I have to solve this with script triggers in the related lay out?

           Hans Lijnbach

            

        • 1. Re: Behavior GTRR if number of records is 0
          philmodjunk

               The trick is to either check for related records just before the GTRR or an error code immediately after.

               You either use:

               If [ not IsEmpty ( RelatedTable::NeverEmptyField ) ]
                   GTRR
                    Other code here
               Else
                    code you want if there are no related records here
               End If

               or
               GTRR
               If [ Get ( LastError ) = 0 // 0 means no error code returned ]
                 Rest of script if there are related records
               Else
                  Script for if there are no related recrods
               End IF

               For more on GTRR, see: The Complete Go To Related Record

          • 2. Re: Behavior GTRR if number of records is 0
            lijnbach

                 O.K. Phil,

                 This works fine, both options. I couldn't find the Get (LastError) at first because of the strange translation. But I found it and it is working.

                 Thanks again Phil,

                 Hans Lijnbach.