Flylib.com

Books Software

 
 
 

Chapter 8. buttons, scripts, and value lists


Chapter 8. buttons , scripts, and value lists

Automation in FileMaker Pro is accomplished via scripts . Scripts are created in a part of FileMaker called ScriptMaker and consist of steps (instructions) that FileMaker executes in sequence. A script can perform a one-step operation, such as switching to a particular layout, or it can contain a complex series of steps, such as selecting a subset of records, sorting them, switching to a report layout, displaying and printing the resulting report, re-sorting the records to their original order, and then returning to the original layout.

There are several ways to execute a script. First, any script can be listed in the Scripts menu, where it can be chosen in the same way that you choose other menu commands. The first ten listed scripts are also assigned a (Mac) or (PC) keyboard shortcut numbered from 1 through 0. Second, you can attach a script to a button on any layout. Clicking the button executes its script.

We'll create the scripts needed to automate a variety of useful functions in Investment Minder, such as adding and deleting records, switching layouts, and generating reports . In the process, you'll get a thorough introduction to ScriptMaker.

In this chapter, you'll also learn about creating and using value lists. A value list is a list of data values that can be attached to a field to make data entry easier and ensure consistency. Finally, we'll perform the few additional clean-up tasks needed to complete the database.



define value lists

A value list is a list of data values you can link to a field. The most common use for a value list is to provide a series of choices for the user , formatted as a drop-down list, menu, radio buttons , or check boxes. Value list examples include yes and no, a list of accepted credit cards or shipping methods , and the days of the week. Investment Minder uses two value lists: Account Type and Yes/No.

Account Type . This list will contain the names of the four account types and will serve two purposes. First, by attaching it to the Account Type field on the Main layout, we can ensure that only these four text strings can be entered for the field and that there's no chance of spelling errors from one record to the next . Second, since you can use a value list as a sort specification, the Account Summary Report can be arranged in an order that matches the tab panels in Main (rather than just listing its sections alphabetically ).

Choose File > Define > Value Lists. In the Define Value Lists dialog box, click New. The Edit Value List dialog box appears.

Click OK to return to the Define Value Lists dialog box.

Yes/No . This value list will be attached to the Taxable field (found at the top of the Main layout). The process of creating this value list is identical to that presented for Account Type.

Name the new list Yes/No . Select Use custom values ; enter the following values: Yes, No, ? ; and click OK.

Taxable field. Switch to Layout mode (View > Layout Mode), select Main from the layouts pop-up menu, and double-click the Taxable field.

Note: Radio buttons are mutually exclusive choices; that is, the user can select only one radio button for a given record.

Account Type field. On the Main layout, double-click the Account Type field (to the right of the Taxable field).

In the Field/Control Setup dialog box, select Drop-down List from the Display as drop-down list and Account Type from the Display values from drop-down list. Click OK.