12 Replies Latest reply on Apr 4, 2013 10:55 AM by philmodjunk

    Creating a Search Menu



      Creating a Search Menu


           I have a search menu on a database with buttons of departments that, when clicked, searches for all active (this is determined by a checkbox set) members of that department.

           The departments are just determined by a drop-down menu, so that text will always stay the same.

           The current script in the old file works fine, but, after looking at it, I was wondering whether there is a better, more intuitive script available to use?  See screenshot of what we currently have.


        • 1. Re: Creating a Search Menu

               You can use a single script for all of these buttons. The name of the department can be passed to the script as a script parameter.

               The portion of your script that performs the find might look like this:

               Enter Find Mode [] ---> clear the pause check box
               Set Field [/*your table occurrence name here*/::Department/School ; Get ( ScriptParameter) ]
               Set field [/*your table occurrence name here*/::Active Status ; "Active" ]
               Set Error capture [on] ---> keeps error dialog from interrupting the script if no records are found
               Perform Find []

               I haven't tried to type in the very long table occurrence names shown in your screen shot so you'll need to put those in where I have text between /* */ brackets.

               For other examples of scripted finds that use set field like this, see: Scripted Find Examples

          • 2. Re: Creating a Search Menu

                 Okay great!  Thank you, as always, for the quick response.

                 So, to make this work, I have set up the menu layout on "Menu | IWP".
                 Would I need to create an additional script step "Go to Layout" at the top of the script, and then perform the find?

                 I placed one button (Dean's Office) on the "Personnel List | IWP" layout just to test it, and it doesn't sort anything.


            • 3. Re: Creating a Search Menu

                   Perform Find[Restore]

                   is incorrect.

                   Make it:

                   Perform Find []

                   And does the buton that performs this script pass a parameter to the script?

              • 4. Re: Creating a Search Menu

                Thank you for finding the error in the script.  I've fixed taht.  Now, the second part of your reply:


                And does the buton that performs this script pass a parameter to the script?

                     I feel a bit stupid for asking this, and it's probably a dumb question, but how do I pass a paremeter to a script?  I feel like I've done this before in another script...but I'm not exactly following how I go about passing a parameter to a script.  I apologize for being difficult

                • 5. Re: Creating a Search Menu

                       When you set up the button to perform the script, there's a point where you have a dialog box open to select the script to be performed. In the bottom of this dialog box is an "option script paramter box". You'd enter the data or calculation needed to pass information as a script parameter in that box. The suggested script won't work without the right text being passed to it via a script parameter.

                  • 6. Re: Creating a Search Menu

                         AH!  Lightbulb moment.  Okay, I think I understand.  So, I'd put the name of the department in that box, correct?  See screenshot.

                         I did that for one button, and it seems to be working.  smiley

                    • 7. Re: Creating a Search Menu

                           That's it. And since each button can be set to have different text in this box, the same script can be used with a bunch of different buttons--each set up with a different script parameter.

                      • 8. Re: Creating a Search Menu


                             Thank you so much!

                        • 9. Re: Creating a Search Menu

                               I have to revisit this and ask the following:

                               I have another database - a mail log - where we have buttons for each academic year, which we use to sort the records.  Currently, the database uses a separate script that is duplicated and updated each year when a new button is added.  Can I apply this same script to sort the records by year, and then use a script parameter to define which year is being sorted?  Can I add dates to the parameter field?

                               The screen shot will make things make more sense.

                          • 10. Re: Creating a Search Menu

                                 It's exactly the same situation and one script with a script parameter can replace all these individual scripts, but you are not "Sorting" records here, you are "finding" them. Using "Sort" when you mean find when talking FileMaker Databases can result in confusion on the part of the person to whom you are communicating.

                            • 11. Re: Creating a Search Menu

                                   Good point about the use of terms.  Didn't think of that.

                                   So, when I define a script parameter, would I enter the sort date in this format: */*/2013 ?

                              • 12. Re: Creating a Search Menu

                                     that works or you can just use: 2013.

                                     You can enter just the year into a date field while in find mode and FileMaker will find all records with that year.

                                     You may also be able to modify your design so that you do not even need to add a new button with each new year. You might consider using a drop down list for selecting the year instead of buttons, just to give one example.