What version of Filemaker are you using?
What is your current table structure?
With this information I may be able to help you.
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.
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
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 ]
Set Field [YourTable::STudentID ; $StudentID ]
Set Field [YOurTable::ProductID ; $ProductID ]
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.
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:
- They aren't unique. You may get two people with identical first and last names.
- They change. People marry, get adopted or just decide their legal name should be different.
- 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.
Yep that's very true! I did the ID field.
Thanks again for the code. It worked great!