It would generally be considered very bad practice to use names as match fields (as you appear to use here). What do you do when you get two people with the same name? Or how robust is your database against data entry variations of the Rob/Robert/Bob, Smith/Smyth/Smythe variety that humans endlessly invent? Or how flexible is it when Miss Smith marries and becomes Mrs Jones?
You should use unique ID numbers to identify the contacts. You can use a pop-up to choose from your existing contacts, and if they aren't there, then go straight to the appropriate table and create them. If there are too many contacts for a pop up then display them in a portal and gradually filter it (FM11 or 12 assumed) and then click on the name when the list is sufficiently narrowed.
But if you insist on going the way you are, then one way would be:
Enter Browse Mode
Set Variable [ $FirstName ; Form::FirstName ]
Set Variable [ $SecondName ; Form::SecondName ]
Go to Layout [Contacts]
Create New Record
Set Field [Contacts::FirstName ; $FirstName ]
Set Field [Contacts::SecondName ; $SecondName ]
Thank you so much for that. I can't beleive I didn't think to do that. it has worked a treat.
I strongly agree with sorbsbuster on this one.
Here's how to set up what we are recommending:
Delete your first and last names from Form. Define a calculation field, cFullName, in contacts as FirstNameField & " " & LastNameField. Define a ContactID field in Contacts to auto-enter a serial number. Define a number field in form and name it ContactID.
Relate your tables like this:
Contacts::ContactID = Form::ContactID
Put Form::ContactID on your Form layout. Set it up as a drop down list pr pop up menu with the "use values from a field" option. Use Contacts::ContactID as the source of values for this value list. Select cFullName in the "also use values from" box.
Add Contacts::FirstName and Contacts::LastName to your layout.
To select an existing contact on a new Form record, select them from this drop down. To create a new contact, use this script:
Go to Layout [Contacts]
Set Variable [$ContactID ; value: Contacts::ContactID]
Go to Layout [original layout]
Set Field [Form::ContactID ; Value::$ContactID]
You can then enter the new contacts first and last names directly into the first and last name fields on your Form layout, but the data is being entered into the contacts record, not the form record.
cheers, thinking about it like that it makes more sense. I shall try and change it
I have made those changes, the only thing with it is that I have 13000 people in the data base so if we could filter them in some way it would be perfect
If these people fall into categories, you can try using a conditional value list where you select a category in field 1 and then the drop down list of contacts lists only people in that category.
Here are some links on conditional value lists:
Forum Tutorial: Custom Value List?
Knowledgebase article: http://help.filemaker.com/app/answers/detail/a_id/5833/kw/conditional%20value%20list
Hierarchical Conditional Value lists: Conditional Value List Question
Feel free to post follow up questions here if those links aren't enough to get your value lists working correctly.
There are also other methods you can use to select a contact from a list by name, but have the ID number entered. Here's a demo file that uses more advanced scripting techniques to search out values by name, but enters the corresponding ID number:
Both demo files are .fp7 files. If you are using .fmp12, you can open them from the file menu to get a converted copy that should work just fine as a converted demo file.