6 Replies Latest reply on Aug 9, 2012 9:19 AM by synergy46

    Script will not delete records?

    synergy46

      Title

      Script will not delete records?

      Post

      I have about 15 tables.

      There is a script that opens a layout based on each table and executes these steps:  (some are redundant, I know)

       

      GoTo Layout - Global (Global)

      Enter Browse Mode

      Show All Records

      Delete All Reords (No Dialog)

       

      This code works on 14 tables; excepting Global.

      I have run deBug and watch the script do exactly what it is designed to do EXCEPT for my global table.  When executed, the above code does NOTHING.  Huh?  What am I missing?

        • 1. Re: Script will not delete records?
          philmodjunk

          Would your Global table be a table of only fields with global storage?

          Remember that those fields store data not dependent on any specific record?

          Check the record count info in the tool bar near the book control and I think you'll see zero records.

          But the global fields still retain their value creating the illusion that you still have records in the table.

          • 2. Re: Script will not delete records?
            synergy46

            Thanks for the reply.

            However I am still confused. 

            As I step through debug, I can see the layout open and records present.  After the Delete command is issued the records are *still* there.  If I goto my Setup Layout it still shows the rercalcitrant records.

            You say:  But the global fields still retain their value creating the illusion that you still have records in the table.

            Why do they 'retain their value' after they are deleted?  Huh? 

            Since I can 'see' the records it begs the question, "How do I delete all the records in the global table AND show no records?"  Do I have to step through each field and replace it's content with "" ????

             

            Thanks again.

             

            • 3. Re: Script will not delete records?
              philmodjunk

              Deleting records and clearing a global field are two different tasks. Global fields aren't part of the records you deleted so they still store a value.

              If you check the circled area, I believe that you'll see 0 records--indicating the the records have all been deleted.

              And yes, if you want to clear the fields, setting them to "" is one way to clear them.

              • 4. Re: Script will not delete records?
                synergy46

                Thanks Phil.  As usual, your insight is spot on.

                 

                Right, no records present.  But, field values persist.  I fixed the problem by grinding through each field and setting it to 0 or "" as appropriate. 

                 

                It works but it surely isn't very elegant.

                 

                Thanks again

                 

                • 5. Re: Script will not delete records?
                  philmodjunk

                  If you were to put all the global fields on a single layout, you could script a loop with go to next field that clears the fields.

                  Save a copy with the clone option will produce a copy of your file with all tables and global fields empty--so that is another option to consider.

                  • 6. Re: Script will not delete records?
                    synergy46

                    Thanks for spreading 'more light'.