2 Replies Latest reply on Sep 17, 2016 1:21 PM by pademo57

    Setting Up a Script to Perform Find with a Pop-Up Menu


      In Filemaker 15 I'm trying to perform a find for an employee in my Report Table which uses the Pop-up Menu that shows all the Employees on the Report Layout.


      I have an Employee and a Report Table. In the Employee table I have a Primary Key __pk_EmpID. In the Report Table I also have a primary key __pk_RptID with an foreign key for the Employee called _fk_EmpID.


      In the Report Layout I used the pop-up menu to show the Employees by creating a Value List which uses values from the first field ( the primary key  - __pk_EmpID from Employee) and the secondary field ( a calculated field of the first and last name of the Employee). I also clicked on "Override data formatting with value list"


      This works great when creating a new report but when I try to set up a script to perform a find I keep getting an error saying it can't find any matching criteria.


      My script uses the Enter Find Mode and then the Perform Find but I don't seem to be able to figure out what criteria to put in to get it to find an employee.


      Can someone walk me through how to get this to work please?

        • 1. Re: Setting Up a Script to Perform Find with a Pop-Up Menu

          We need to see your script to know how and why it failed.


          Did you select the employee and then enter find mode or did you enter find mode and then select the employee?


          If you did the first, you are doing data entry on the current record and then entering find mode and that then fails.


          If you enter find mode, pause so that the user can select an employee and then perform the find, this should work though it's not the approach that I prefer for this type of thing.


          I prefer to set up a field with global storage used solely for entering search criteria for the scripted find. You can put the global field inside a popover with a button inside the popover used to perform the find.


          Your script might then look like this:

          Enter FInd Mode [] --- clear the pause check box

          Set field [YourTable::YourEmployeePrimaryKeyFieldHere ; YourTable::globalFieldWithPopupMenuHere ]
          Set Error Capture [on]

          Perform Find []

          If [ Get ( FoundCOunt ) = 0 ]

            Show Custom Dialog ["Error, no records found"]
          End If



          Note that "restore" does not appear for either Enter FInd mode nor for Perform Find.

          • 2. Re: Setting Up a Script to Perform Find with a Pop-Up Menu

            Thanks philmodjunk,

            I realize now that I was trying to use the base table instead of the TO which is related and as soon as I switched it then it worked.

            Thanks again.