3 Replies Latest reply on Apr 28, 2014 10:32 AM by philmodjunk

    delete button deleting ALL rows in the table

    BillPlunkett

      Title

      delete button deleting ALL rows in the table

      Post

           I have a layout that has a button to add a new record to the table.  It performs a script that adds the record and changes a couple fields in 2 different tables.

           I HAD a button to delete the currently displayed record but when I used it, it would delete all the records in the table.  So I deleted the button and used the button a in the main too bar - it does the same thing.

           Here's the scenario:  I add one new record with the custom add button and immediately delete it with the toolbar button, all is well.  If I add 2 records and then delete the last add record - all records are deleted.

           what's wrong???

        • 1. Re: delete button deleting ALL rows in the table
          mgores

               Manage-Database- Relationship tab

               Check your relationships and see if the "Delete related records in this table ..." box is checked for any cases where it would cause that to happen.

          • 2. Re: delete button deleting ALL rows in the table
            BillPlunkett

                 OK, removing ALL the "delete when..." checkboxes fixed the problem.

                 But WHY?  Seems if I delete a record in the main table view, that it is reasonable to delete the record in the portal view.  So, why does it delete everything?

            • 3. Re: delete button deleting ALL rows in the table
              philmodjunk

                   That would depend on what options you specified in the relationship. Correctly set up, the "delete" option will do exactly that. Set up incorrectly, and you get a "cascading delete" that can delete far more records than you want.

                   Say you have this one to many relationship:

                   LayoutTable-----<PortalTable

                   where the two table occurrences refer to different data source tables. This should not be a self join for this example.

                   If you double click the line between the two occurrences and select the delete option only for the Portal table, then deleting a record in LayoutTable will also delete all and only the related records in Portal Table.

                   But a delete option affects what happens when a record in LayoutTable is delete no matter what layout you are on and no matter what table occurrence of LayoutTable is specified for that layout.