7 Replies Latest reply on Aug 19, 2010 7:34 AM by developerS

    performing a scrip to diplay record

    developerS

      Title

      performing a scrip to diplay record

      Post

      hi,

      I have a databse with a number of forms. Home page has a number of buttons that link to each of the various forms, as well as two fields that users fill with their name and age. The fields àge`and `name`are in every form. I am running a script on the button that will take the user information and automatically populates the name and field it in every form they choose to fill out.

      I do NOT want a user to be able to fill out the same form twice. So I need the script to first look up a record and display it if found, if not to create a new record with those demographics.

      Can anyone help me with this? I ahve been trying to figure it out for days. Doing research and everything. No luck.

      Help please!


        • 1. Re: performing a scrip to diplay record
          Frinholp

          What version of Filemaker are you using?

          What is your current table structure?

          With this information I may be able to help you.

          Lee

          • 2. Re: performing a scrip to diplay record
            philmodjunk

            Use set Error Capture [on] first to keep filemaker's "No records found..." dialog from popping up and getting in the way.

            Perform a find ( the details depend on your design ) that will find such a record if it exists.

            Count the records (an If step with Get ( FoundCount ) )

            If there are zero records found, start a new record.

            There are other ways that use a relationship between your tables for this.

            • 3. Re: performing a scrip to diplay record
              developerS

              I am using filemaker pro 11.

              My database is set up as follows:

              My home page has student name and age. That the student enters

              After i have around 4 buttos each linking to different forms (tables) --. each t5able has the fields student name and age and a couple of other fields depending on the form (such as courses, hobbies, Extracurricular activities, etc.

              I know how to automatically populate the name age and date in each form with a script when the button is pressed. but every time it creates a new record. which is bad.

              I want an if statement

              • 4. Re: performing a scrip to diplay record
                philmodjunk

                I don't see any reason to copy all that data into each of the other tables. Just a studentID and a productID should be sufficient.

                Set Variable [$StudentID; Value: Home::StudentID ] //this should be a unique serial number, not a name
                Set Variable [$ProductID ; Value: Home::PRoductID ]
                Go To Layout [YourTable //select the appropriate layout here]
                Enter Find mode []
                Set Field [YourTable::StudentID ; $StudentID]
                Set FIeld [YourTable::PRoductID ; $ProductID]
                Set Error Capture [on]
                Perform Find []
                If [ Get ( FoundCount ) = 0 ]
                   New Record/Request
                   Set Field [YourTable::STudentID ; $StudentID ]
                   Set Field [YOurTable::ProductID ; $ProductID ]
                End IF

                • 5. Re: performing a scrip to diplay record
                  developerS

                  Oh i am not adding all the fields in the table all im adding is the name and age the other attributes vary from form to form and the students fill them in.

                  Only common fields are age and name, and i should add Id maybe.

                  Thanks!

                  • 6. Re: performing a scrip to diplay record
                    philmodjunk

                    Age and name should be a student table where you have one record per student. Then use a StudentID number in this table to link to the student table to see all the student information such as name and age whenever this is needed.

                    The problem with names is three fold:

                    1. They aren't unique. You may get two people with identical first and last names.
                    2. They change. People marry, get adopted or just decide their legal name should be different.
                    3. They're error prone. You enter the name John Smith in your system and link a bunch of records by this name to John Smith and then discover his name is John Smithe or John Smythe...

                     

                    Using a serial number instead of a name avoids problems dealing with all three of these issues.

                    • 7. Re: performing a scrip to diplay record
                      developerS

                      Yep that's very true! I did the ID field.

                      Thanks again for the code. It worked great!