5 Replies Latest reply on Nov 8, 2013 3:06 PM by RobMacy

    parent key foreign key agrement

    RobMacy

      Title

      parent key foreign key agrement

      Post

           In the data base my parent table is ptInfo (patient information)  it has a parent key of ptIDnumber. When I create a netreatment record (Tx) the ptIdnumber fK  should populate from the current ptInfo record.  The relationships seem to b et right but the field  remains blank.  My screenshot includes the inspector.  What am  missing?

            

      Thanks

      Rob

      Screenshot_%282%29.png

        • 1. Re: parent key foreign key agrement
          philmodjunk

               It won't happen automatically. FileMaker can't read the user's mind to know to what record in the parent table to link this new child table record.

               The fk field can be formatted with a value list for selecting the correct parent record or a script on the parent record's layout can set a global variable or field with the parent key value of the current record and you can define an auto-enter calculation on the child record's fk field to auto-enter the value of that global variable or field.

               You can also use a portal on the parent table layout to create related records in the child table. If "allow creation of records via this relationship" is enabled for the child table, you can add new related records in the portal simply by entering data into blank fields in the portal and FileMaker will copy over the matching key value for you.

          • 2. Re: parent key foreign key agrement
            RobMacy

                 Thanks PhilModJunk.  So lemme get this straight.  On the button in my larent table(ptInfo) i'm going to place a script that changes layout to Tx then sets a global variable with the field ptIdNumber value in its ptIdNumber field and sets the field value in the Tx layout ptIdNumber field.

                 Is that the jist?

                  

                 Thanks Rob

            • 3. Re: parent key foreign key agrement
              philmodjunk

                   But you have it backwards. It has to set a global variable first, then it can change layouts. It has to get this value from the current record on your parent layout.

                   And this will still not do anything for you unless you define the fk field to auto-enter the value of this global variable.

              • 4. Re: parent key foreign key agrement
                philmodjunk

                     And the OnRecordLoad script trigger can be set up on the parent record layout to perform a script to set the variable so that the variable is automatically updated each time you change or create a parent record on that layout.

                • 5. Re: parent key foreign key agrement
                  RobMacy

                       AHHHHHHHHH!!!!  This makes sense thanks for your help on this PhilModJunk. :)