2 Replies Latest reply on Aug 10, 2015 11:31 AM by Auzzie

    In a "Parent" layout, review a Child table's field, select and create relationship

    Auzzie

      Title

      In a "Parent" layout, review a Child table's field, select and create relationship

      Post

      Sorry for such a dumb question but what in the simplest way when in a Parent layout to create a view/look-up of a Child table's field entries, make a selection from the entries and then populate the foreign key on the child table with the primary key of the Parent. to create a relationship. I know how to create the relationship when in the Child layout to create a relationship with the Parent but not vice versa. Again, sorry to waste your time on a what is such a stupid question.

        • 1. Re: In a "Parent" layout, review a Child table's field, select and create relationship
          philmodjunk

          Your description of what you want to do is somewhat contradictory. You want to select a child record and link it to the current parent record, but technically it isn't really a child record until you link it and you have to have a relationship in place linking the child record to the current parent record before it can be accessible. It's a bit like using your cell phone to tell the cell phone service provider that you don't have any cell phone service. wink

          But, assuming that you are selecting an existing record from the "child" table not creating a new related child record, there is a way to do what you want by using two relationships to two different occurrences of that "child" table. Say you set up these relatinships:

          Child>----Parent>-----x----<Child|All       ----< means "one to many"

          Both Child and Child|All are table occurrences with the same data source table.

          Match Fields:

          Parent::__pkParentID = Child::_fkParentID
          Parent::anyField X Child|All::anyField

          This would allow you to put a portal to Child|All on your Parent layout and the X operator would then enable FileMaker to list all records in the child table. You could then put a button in the portal row of this portal with this simple script step:

          Set Field [Child|All::_fkParentID ; Parent::__pkParentID]

          Clicking the button would then link that record from the child table to the current parent record. But a word of caution: If the selected record from Child|All is already linked to a different record in the Parent table, clicking this button also disconnects it from the link to that other parent record. You may want to either use a script that first verifies that the _fkParentID field is empty and warns the user if this is the case or set up a portal filter to omit all records where this field is not empty.

          • 2. Re: In a "Parent" layout, review a Child table's field, select and create relationship
            Auzzie

            Excellent! Thank you this was extremely helpful.