2 Replies Latest reply on Dec 21, 2009 12:34 PM by philmodjunk

    Adding records through a portal



      Adding records through a portal


      I have a table (Table1) with a portal for a related table (Table2). Table2 has a primary key with the option auto-entry set for a serial number and validation set for unique value. Using this primary key I have linked to Table1 to a foreign key. I have set the relationship so records can be added to Table2. I can add one record from this portal. However, if I try to create another record I receive an mesage box tha says "The primary key is defined to contain unique values only. You must enter a unique value." Since I set key to auto-enter a serial number I expect it would have happened. What am I doing wrong?



        • 1. Re: Adding records through a portal

          Howdy jconner99,


          I think you have all the tools, but your trying to use the hammer on the pointy end of the nail...use it the other way around.


          Your primary key goes on Table1.  Your foreign key goes on Table2.


          With the portal from T2 into a layout based on T1, you are trying to make many records in T2 related to the record on T1.


          T2's ID can't be unique...you have many that have to be the same as T1.

          Make T1's unique and remove the autoenter on T2...the ID will get set on T2's records when you create it through the relationship.


          Am I clear enough, or too vague?

          • 2. Re: Adding records through a portal

            When you enter data on the blank line of your portal, Filemaker creates a new record and automatically assigns the current record's key field value from Table1 to the matching field in table2. Since you have defined this field as a unique values only field, the second such record enters a duplicate value and triggers the error message.


            I think you have things backwards here. Is your relationship linking your two tables like this?


            Table1:key --=--<table2:key


            In otherwords, do you expect there to be many records in table 2 that match one record in table 1?


            If so than you need a Primary Key in Table1 instead of Table2.


            Make the key field in Table1 and auto-entered serial number and the key field in table2 just a number field.