3 Replies Latest reply on Jun 9, 2011 9:11 AM by philmodjunk

    Set Field by Name

    LouisJohnson

      Title

      Set Field by Name

      Post

      I am new to Filemaker Scripts, and am doing something wrong, but cannot guess what.

      When I am in the table DaveProspects, enter a first name and a last name and then run the script, it is supposed to check whether that name exists in the table DaveAddresses. If not, it should a create a new record there and copy into it the first and last names.

      When no such record is found, a new record IS created, but nothing is copied into it.

      FM_10_Set_field_by_name_problem_script.JPG

        • 1. Re: Set Field by Name
          philmodjunk

          Best guess is that you do not have a field named "Add First Name" in the DaveAddresses table nor a field named Add last Name. It could differ by as little as a single character and this won't work.

          Instead of using set field by name, use set field and select the field you want to set in the drop down list of field names.

          When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Click OK. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.

          • 2. Re: Set Field by Name
            LouisJohnson

            Thanks, Fhilmodjunk.  I did run into those problems and found my through them.

            When the script runs, the current window loads in the Addresses layout, creates the record, and the new record is selected.  I wonder whether that makes the script lose focus on the record in the Prospects layout so it doesn't know what record to copy the names from.

            Would it help to create a new window, somehow set that window to go to the addresses layout and create the record?  Would having two windows maintain focus on both records?

            With hundreds of names to enter it sure would be nice to type each one only once!

            • 3. Re: Set Field by Name
              philmodjunk

              Different issue there. Unless there is a relationship between the two tables, you can not directly reference fields from the other prospects while you are on the address layout. If there is a relationship, the relationship will determine which record supplies the data and this will have nothing to do with which record is the current record on the prospects layouts.

              To move data from one table to another in a script like this, you may need to use a variable:

              Set Variable [$Value ; Value: YourTable1::Field]
              Go To Layout [Table2Layout]
              Set Field [Table2::Field; $Value ]