3 Replies Latest reply on Jun 30, 2014 10:15 AM by TSGal

    Saving a copy of a layout from a related table



      Saving a copy of a layout from a related table


           I've tried to find an answer but so far haven't been successful. I'm still kind of a newbie.

           I have a table that randomizes various ingredients for dinner ideas and a related table that has a layout to save the identical info.

           My dilemma is that when I hit the save button where I duplicate the info in a saved layout, I want to reset the original layout so there are no existing recipe combos but KEEP the saved one.

           Because I'm using a foreign key on the Saved layout to lookup the same items, whenever I delete the original, it deletes the saved one.

           How can I save to another layout, delete the original but keep the saved one?

        • 1. Re: Saving a copy of a layout from a related table

               I admit I have no idea what you're trying to accomplish. What is a saved layout? Records are records and can be saved. Layouts show records. What is it you wish to delete? I'm not trying to be argumentative. I simply am not understanding.

                    Having reread your post perhaps you need to simply create a new record (which will be blank) on your original layout.

          • 2. Re: Saving a copy of a layout from a related table

                 Sorry, I should be more clear.

                 I need to be careful with my terminology. I'm using two identical tables that have the same fields. Menu Ideas and Saved Menus.

                 I have a layout with six fields that use a random calculation to fill each field with a random choice from six separate value lists. For example, cooking method, type of protein, flavor, etc. This is based on the Menu Ideas table.

                 After the randomized choices appear, the choice is to either exit or save the combo as a saved dinner idea. (Uses a button)

                 To populate the fields on the SavedMenus layout, I used a foreign key to look up the fields with a relationship between the two tables. 

                 Each time the application starts, I want to remove all the original records except for the saved ones chosen by the user.

                 When I delete the original, I haven't figured out how not to blank out the Saved Menu since it's looking up the fields from the original based on the primary key.

                 How can I copy the fields from the first randomized layout from Menu Ideas into the identical layout in Saved Menus effectively without resorting to some kind of clunky script that just copies each field and pastes each one into the other one?



            • 3. Re: Saving a copy of a layout from a related table

                   Jeff Broderick:

                   Thank you for your posts.

                   Just duplicate the original record.  This leaves the original record and creates a new record with a new Primary key (assuming the key field is set for Auto-Enter serial number).  The related records will then be blank.  You can then add the desired records to the new record.

                   However, it sounds like multiple recipes can have the same items, thereby having a many-to-many relationship.  Therefore, you will need a third table to link the records to each other.  The third table would include the primary key from the first table along with the primary key from the second table.  You can then use the same ingredients again with a different recipe.

                   FileMaker, Inc.