Go to Tab script


Go to Tab will be the first multi-step script we'll create. This script is responsible for displaying the appropriate tab for the current investment record in Main and will be attached to the Tab button above the Main layout. The reason we're creating it first is because this script is also called (executed) by several other scripts. Like other multi-step scripts, it must be created in ScriptMaker, FileMaker's script-editing tool. Here's the script as it will look in the Edit Script dialog box:

This script uses an If and a series of Else If steps to determine what data the current record has stored in the Account Type field. As soon as an If or Else If test has been satisfied, the step immediately following the test is executed. Then the script skips any additional tests and jumps directly to the End If step.

Thus, when a match to one of these text strings is found (Savings/Money Mkt, Stock/Mutual Fund, CD, Savings Bond), a Go to Field step is executed that displays the specified field. Since each field is present on only one tab panel (for example, CD_Institution occurs only on the CD tab panel), this step forces the correct panel to be displayed.

The Else step near the end of the script is a catch-all that handles records for which no Account Type has been specified or in which you've manually entered a different text string. The Show Custom Dialog step presents a dialog box to the user, explaining that a selection must be made for the Account Type field. Until this is accomplished, the correct tab cannot be displayed.

Choose Scripts > ScriptMaker. The Define Scripts dialog box appears.

Move an If step into the script by double-clicking it in the step list (or by selecting it and clicking Move.) An If step is used to conduct a logical test. In this case, we'll combine it with a series of Else If steps to determine the Account Type of the current record.

Double-click the Account Type field in Main's field list to insert it into the formula. Then type the rest of the formula. Be sure that the text in quotes is copied exactly. Click OK to close the dialog box.

The If step in the script is now modified to include this test within its parentheses.

The step immediately following the If step is executed if the test is passed; that is, if the current record's Account Type field contains Savings/Money Mkt. In that case, we want to display the Savings/Money Market tab panel. The way to accomplish this is to go to a field that is only present on the target tab.

With the If step selected in the script, add Go to Field as the second step. (New steps are inserted immediately after the currently selected step.) Click the Specify button. In the Specify Field dialog box, select Sav_Institution from the Main table, and then click OK.

Insert an Else If step to follow the Go to Field step. If the If test fails (that is, Account Type is not Savings/Money Mkt), this new test is performed.

Click the Specify button. In the Specify Calculation dialog box, create this formula:

 Main::Account Type="Stock/Mutual Fund" 

Insert another Go to Field as the step to be executed if the Else If test is passed. Click the Specify button, select the Stk_Brokerage Firm field in the Specify Field dialog box, and click OK.

Insert two additional Else If/Go to Field pairs to test for the other Account Type entries, as follows:

 Else If [Main::Account Type="CD"]         Go to Field [Main::CD_Institution] Else If [Main::Account Type="Savings Bond"]         Go to Field [Main::Bond_Serial#] 

Insert an Else step. When all tests fail, the step following the Elseif there is an Else stepis automatically executed.

Insert a Show Custom Dialog step (found in the Miscellaneous section of the step list) and click Specify. The "Show Custom Dialog" Options dialog box appears. The specified Title will be used as the dialog box's title, Message will be the text presented in the dialog box, and the Button entries determine which buttons will appear at the bottom of the dialog box and their labels.

Note: When entering text in this dialog box, it isn't necessary to type the quotation marks. FileMaker adds them for you.

Ensure that the script concludes with an End If step. Then click OK. The Define Scripts dialog box reappears.




Creating a Database in FileMaker Pro 8. Visual QuickProject Guide
Creating a Database in FileMaker Pro 8: Visual QuickProject Guide
ISBN: 0321414837
EAN: 2147483647
Year: 2005
Pages: 115

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net