4 Replies Latest reply on Jul 20, 2015 4:00 PM by MauriceG

    Script that creates new records

    MauriceG

      Title

      Script that creates new records

      Post

      Hello all,

      My library db has a table Books (1100 records) that contains all the fields I'm using. A big mistake from the start. One of these fields is Authors. I now want to create a table Authors and new records for all the authors. I know it's doable by script. I searched this forum quite extensively and found one post where the situation described is almost identical to mine.  Create related record through script But it is not completely identical because some of my books have more than one author, and the script suggested by PhilModJunk assumes that there is only one author per book. I have no clue how to tweak that script so that it would work for me. Help would be greatly apprreciated.

      Thanks.

       

        • 1. Re: Script that creates new records
          MarkGores

          A join table between the book and author table that allows each book to have more than one author and each author to have more than one book.

          • 2. Re: Script that creates new records
            MauriceG

            Thanks. I have already created that join table. But I still wonder whether the script suggested in the referenced thread above will deal with my situation where several books have more than one author.

            • 3. Re: Script that creates new records
              SteveMartino

              Considering these 2 lines from Phil's post:

              I'd consider setting up the join table right off as a book can have multiple authors and an author can write multiple books. The same script can create both the author records and the join table records at the same time.

              and 

              Duplicate author records will not be created as long as your author names are accurate in the Library table as these steps create a new record only if a matching related record does not already exist

              • 4. Re: Script that creates new records
                MauriceG

                Thanks Steve. I'm not sure I am following however. Are you saying the script suggested by Phil will do the job for me even though some of my books have multiple authors (in the same Authors field)?

                As further clarification, in the Authors field of my Books table, the authors (3 in this exemple) are shown like this right now, separated by a carriage return:

                Mandela, Nelson

                Mandelbaum, Michael

                Steinbeck, John

                Will the suggested script create three separate records?