3 Replies Latest reply on Aug 3, 2015 12:14 PM by philmodjunk

    Creating a simple 1 to many layout view......

    jon@thanspence.com

      Title

      Creating a simple 1 to many layout view......

      Post

      I am new to Filemaker (I understand relational databases and have used Microsoft Access 2003 many years ago) I have created 2 tables... Expense Period and Expenditure see below....

      And have set the relationships as follows:

      I have then tried to create a layout, so that I had a Period view and a portal to display the related expenditure details. However, when I press Add new record it creates a new period record rather than an expenditure record. How do I stay on the same period record and create multiple expenditure records for the period record. 

       

        • 1. Re: Creating a simple 1 to many layout view......
          jon@thanspence.com
          /files/1a2aa56642/relationships.jpg 3266x3149
          • 2. Re: Creating a simple 1 to many layout view......
            SteveMartino

            Your pics/screenshots didn't come thru. Edit: now they did...

            There are many ways/flavors of doing this:

            If you have 'allow creation of records via this relationship' checked for the portal side of the relationship, typing into the empty row, any field, will create the related record.  In one instance I have a trigger set up to auto enter todays date, thus creating the start of a new child record, when I tab into the first portal record (portal sorted descending), the trigger goes to the last portal row, enters the date, commits the record (so the portal row you are working on jumps to the top).

            If you don't have 'allow creation checked', you can create a button and script the process, doing some of the stuff I described above.

            • 3. Re: Creating a simple 1 to many layout view......
              philmodjunk

              You have two choices:

              a) Open Manage | Database | Relationships, double click the relationship line to open up the "Edit Relationship" dialog and enable "Allow creation of records via this relationship" for Expenditure.

              Now you'll find that a new, blank row appears in the portal just below the last related record. If you enter data into one of the fields in this row, FileMaker creates the new related record for you and copies over the match field value to link it to your current layout (Period) record.

              b) Put a button on your layout. Set it to perform a script that creates the new portal record. There are several ways a script might do that, here's a commonly used method:

              Set Variable [$Period ; value: Period::PrimaryKey //use your field name in place of mine ]
              Go to Layout ["Expenditure" (Expenditure)]
              New Record/Request
              Set Field [Expenditure::ForeignKey ; $Period ]
              Go to Layout [original layout]

              Many developers use a button with a script so that they can put a sort order on the portal that puts the new record at the top rather than the bottom of the portal.