5 Replies Latest reply on Feb 2, 2016 5:27 PM by DanielShanahan

    Adding/Assigning Parent Record from Child Layout

    jgetman

      First off, I'm a beginner, so I'm probably asking a silly question.  I actually hope I am, because it means I'm making things too hard. 

       

      I am creating a database in which there is a child table that has two parents. (Which is really just a join table, I know, but my problem still remains.)  I need to have the choice of assigning the second parent to the child, or creating a new second parent from the child, in the child layout. No matter what I do, I can't figure out how to make either of those things work. I'm sure it's a scripting thing...and I haven't yet wrapped my head around difficult scripts.

       

      I've attached an example that shows the build I've come up with. Feel free to correct any odd things I've done. I'm really looking forward to figuring this out.

       

      Thanks!

        • 2. Re: Adding/Assigning Parent Record from Child Layout
          jgetman

          Hi, Daniel. This definitely helps. Thank you!  I can see that I was trying to make this part of the solution too hard.  Discounting the finds and the exit commands, what I see is that you a) created a new MasterCueInstance (parent) record and saved a variable based on its primary key, b) went back to the CueInstance (child) layout and set the field MasterCueInstanceID_fk equal to the primary key of the MasterCueInstance (parent) record, and c) went back to the MasterCueInstance (parent) layout.  Great! This makes sense, and I appreciate the lesson!

           

          I'm going to credit you on the final draft of the app once I'm done, if you don't mind.

           

          So now my problem is the other (and likely more difficult) part of the equation: assigning the CueInstance (child) record to an existing MasterCueInstance (parent) record.  Because the child record isn't already connected with the parent record, I'm guessing that some form of the parent table is going to need to be global so that the child record can even reach that table to choose.  I've run into the "magic key" method, which I think will make this possible.  (Some posts on that can be found here and here.) Is that correct? Or is that a rabbit hole I don't even want to try to enter at this point?

           

          Thanks again, Daniel.  Anyone who has thoughts on the other half of the question, I'm all ears/eyes.

          • 3. Re: Adding/Assigning Parent Record from Child Layout
            DanielShanahan

            jgetman wrote:

             

            Hi, Daniel. This definitely helps. Thank you!  I can see that I was trying to make this part of the solution too hard.  Discounting the finds and the exit commands, what I see is that you a) created a new MasterCueInstance (parent) record and saved a variable based on its primary key, b) went back to the CueInstance (child) layout and set the field MasterCueInstanceID_fk equal to the primary key of the MasterCueInstance (parent) record, and c) went back to the MasterCueInstance (parent) layout.

            You got it!  Glad it makes sense and is helpful.

             

            So now my problem is the other (and likely more difficult) part of the equation: assigning the CueInstance (child) record to an existing MasterCueInstance (parent) record.

             

            When you are on the child table/layout (CueInstance) you can set the foreign key using a popup menu.  Check the sample file again.  In the upper right are two popups for setting the parent keys.

             

            SetForeignKey.png

            • 4. Re: Adding/Assigning Parent Record from Child Layout
              jgetman

              Hi, Daniel.  Ah. I missed all that work you did up there in the top corner--sorry! Now that I see it, I see what you've done with assigning the parent record.

               

              I think I confused myself a couple steps back in my building process, because I had basically gotten it but thought it wasn't working right.  But it was, and it's correct, and it's much easier than what I thought I was going to have to do!

               

              Thanks again! You just saved me hours of going in needless circles.

              • 5. Re: Adding/Assigning Parent Record from Child Layout
                DanielShanahan

                No problem.  Glad it makes sense.

                 

                Good luck!