7 Replies Latest reply on Dec 7, 2011 11:32 AM by philmodjunk

    Simple find script



      Simple find script



      Just need to get a simple Find script working.

      What I have is ...

      In current layout

      EnterFindMode [Pause]

      GoTo Field::Companies   *** where I would type in part of the Company name



      No matter what I do, it keeps hitting the same one record.

      Any ideas?




        • 1. Re: Simple find script

          If you manually enter find mode and type in the same company name into this companies field, can you find the expected records that way?

          Is companies a field of type number or type text?

          In layout mode, do you see ::companies as the field name or companies (no ::)? If you see ::companies, this could be why as this indicates that Companies comes from a related table. When you specify find criteria in a field from a related table you are telling fileMaker to "find all records in the layout's table that have at least one related record matching this criteria." Thus, the record you are getting may have more than one related record and it is another, not visible related record, that is matching your company name criteria.

          • 2. Re: Simple find script

            On a form layout, native to its table.  There are no related fields relevant to this thread.

            Company is a text field.

            It works fine when I do a manual find.

            Very frustrating.   What am I doing wrong?



            • 3. Re: Simple find script

              Do you have

              Perform Find[]


              Perform Find [restore]  ?


              To post a script to the forum:

              1. You can upload a screen shot of your script
              2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF.
              3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
              4. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional look to your script. (Use the HTML option and paste the text into the Forum's HTML editor.)
              • 4. Re: Simple find script


                I had [Restore].    Made that go away, and it works now.


                Except -- the script goes to CompanyID instead of Company.  Have to manually tab to Company.

                 EnterFindMode [Pause]

                Go to Field [Companies::Company]     *** The form is based on the Companies table.

                Perform Find []


                Really what I'd like is to hit a button, have a field come up to Company and just type any desired text.  I'm short-cutting around that as it seems prohibitive to accomplish right now.




                • 5. Re: Simple find script

                  Do it this way:

                  enter find mode [] //no pause
                  go to field
                  pause /resume [indefinitely]


                  See why that works?

                  • 6. Re: Simple find script


                    Yup, it works great.

                    Except you have to hit Enter twice, but that's being *waaaay* too picky.

                    I like that it goes back to Show All.

                    • 7. Re: Simple find script

                      I personally don't set up scripted finds like in this manner. It's so similar to how the user can do their own ad hoc finds (the bane and boon of Filemaker database interface design...), that I don't bother to make the effort.

                      If I find that I need to provide scripted support for searching the database, as is often the case, I use a script that uses new window to pop open a small floating window that simulates a modal dialog. The user specifies criteria in global fields in this window and then clicks a button to close the window and perform the find. The script performed by this button click then uses the data in the global fields (Data in global fields can be accessed while in find mode), to build the needed find request(s) and performs the find.

                      This approach allows me to set up interface details customized to specifying find criteria such as drop down lists with trigger controlled scripts and field validation rules in place to catch obviously invalid find criteria before the user attempts the find. I've even added a calculation field that uses the criteria entered to contstruct a plain language description of what the find will produce to help the user understand what they'll get.

                      You can see an example of this method in the Known Bugs List Database that I created and maintain on behalf of this forum.