Creating a basic FileMaker Pro database that can manage your information is so easy, you might be tempted to stop learning once you know how to define fields (such as name, user, and date) and design layouts. But if you take FileMaker Pro one step further – adding buttons that activate scripts – you can automate your databases and customize them to meet specific needs.
Scripts are powerful tools in any program. In FileMaker Pro they’re also a snap to create. Thanks to the program’s ScriptMaker feature, you don’t have to learn a word of code to create buttons – just select from the commands FileMaker provides. You can script buttons that automatically perform a variety of tasks, such as switching among layouts, finding a set of records, sorting records, checking spelling, and even sending an e-mail message.
To tap into the real power of buttons and scripts, experiment with
scripts – one-step subscripts combined in a larger master script. Nesting scripts let you trigger a string of tasks with the click of a button. The script in our sample project, for instance, finds all the incomplete items on a to-do list, sorts them by two criteria, and displays them in a list view – all with one simple click. Once you get the idea, there’s no limit to what you can do with FileMaker Pro’s buttons.
FileMaker Pro consultant SCOTT LOVE is still trying to live down the goofy interface he built for his first professional database more than a decade ago.
1. Get Set Up
Before you can begin creating this sample script, you have to set the Find and Sort criteria. If you perform a find and sort with the right criteria just before you create the script, FileMaker Pro will apply those criteria to the script.
Begin by creating a database that manages a simple to-do list. You’ll need at least two layouts – a list layout (in this example, List By Client) and a standard layout (in this example, Task Details) – and the following fields: Task_Name, Owner, Client, Task_Notes, and Complete_Date.
To set up sorting, open the Sort Records dialog box (in version 5, Records: Sort; in version 4, Mode: Sort). Add the fields you want to sort by – in this example, Client followed by Owner – by double-clicking on their names in the list on the left
2. Create Subscripts
To create a button that lets you perform multiple tasks, you must assign it a script that contains subscripts. That’s where ScriptMaker comes in.
To create the second subscript, begin in the main ScriptMaker window. Enter a name for the subscript name, for example, Sort By Client And Owner, and click on Create. Just as you did before, remove the default commands and scroll through the list of actions on the left, but this time double-click on the Sort command. Leave both the Restore Sort Order and Perform Without Dialog options selected, and click on OK. Now you’ve got two subscripts ready to go.
You can reuse subscripts. For instance, you can assign a subscript its own button or combine it with other subscripts to create new master scripts.
3. Create a Master Script
Now it’s time to put the subscripts into the final script using ScriptMaker. Once you’ve nested them and added an additional command, your script will let you find incomplete tasks, sort by client and owner, and switch to your list layout.
Next, double-click on the Go To Layout command. Select the name of your list view (here it’s List Incomplete By Client) from the pop-up menu. Leave the Refresh Window option unselected. (It’s necessary only in certain circumstances – for instance, when you’ve updated calculations or relationships – and it slows things down.) Now click on OK. Your scripting is finished, so click on Done in the main ScriptMaker window.
4. Build a Button
Now it’s time for our button to make its appearance. Attaching scripts to buttons is simple-just remember to attach a script to the button you create before placing it on layouts in your database. This will save you some grunt work.
5. Add a Finishing Touch
If you’re not satisfied with FileMaker’s generic buttons, here’s one last user-interface tool for your repertoire: buttons with custom graphics. This step is optional, but it’s simple, and you can use the same technique to spruce up any layout.
In version 5, select Picture from the Insert menu. In the Picture dialog box, select the image you want; it will appear on your layout when you click on OK. In version 4, choose Layout mode, and open the Import Picture dialog box (File: Import/Export: Import Picture) to find the image you want for your button and put it in your layout.
Keep in mind that if you share this database across a network, custom images will cause your layouts to load more slowly. Be sure to test your database before going nuts with custom icons.
Here is the final result of performing the script