Take Control of FileMaker Pro

Today's Best Tech Deals

Picked by Macworld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

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 nesting 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.

Next, set the Find function to bring up all records with an uncompleted task - records with an empty Complete_Date field. Go to the Find mode (in version 5, View: Find; in version 4, Mode: Find), enter an equals sign (=) in the Date Completed field A to search for empty fields, and click on the Find button B.

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 C.

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.

Choose ScriptMaker from the Script menu, and enter a name (in this example, it's Find Incomplete Tasks) in the Script Name field. Click on Create and, in the resulting window, click on Clear All A to remove the default script commands. Scroll down the list of commands on the left and double-click on Perform Find B to move it into your script C. Leave the Restore Find Requests option selected D, so your script will use your most recent Find criteria - in this case, the equals sign in the Date field. Click on OK, and you've completed the first subscript.

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.

TIP: 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.

In the main ScriptMaker window, give your master script a name (in this example, it's List Incomplete By Client) and click on Create. Clear the default script commands A in the Script Definition window, and double-click on the Perform Script command B. Leave Perform Subscripts checked, select Find Incomplete Tasks from the Specify pop-up menu C, and click on OK to finish nesting your first subscript. To nest the second subscript, double-click on the Perform Script command again, but this time select Sort By Client And Owner from the pop-up menu.

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.

Go to Layout mode and click on the Button tool A. Click and drag the cursor across your layout until you get the button dimensions you want B. In the resulting dialog box, select the Perform Script command C and then choose List Incomplete By Client from the Specify pop-up menu D. Leave the Pause option selected (it won't affect this function), and choose the button style you prefer E. (To pick a button type in version 4, you must go to Edit: Preferences: Application: Layout.) Click on OK, and then complete the last step: type a label for your button in the layout.

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.

Use the guide corners of the image to resize it if you wish. Then, under the Format menu, select Button. Finally, assign a function to the custom button, just as you would for a regular button.

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

1 2 Page 1
Page 1 of 2
Shop Tech Products at Amazon