Now that you've created your first script, you should be ready to make the others. For each one, I'll describe what the script does and point out any critical steps you might not readily understand. I'll explain later how to attach some of these scripts to buttons and how to list others in the Scripts menu.
Prev Record, Next Record. This pair of scripts will be attached to the navigation buttons at the bottom of the Main layout. When clicked, you'll switch to the previous or next record in the current sort order. By calling the Go to Tab script as the final step, the matching tab panel for the record will automatically be displayed. The scripts are identical other than the first step's option.
Resize Layout. When necessary, this one-step script will quickly adjust the size of the current layout. Later, we'll assign a / combination to it.
Sort Main. This script will be attached to the Sort button at the top of the Main layout, enabling you to restore the sort order for the table after adding records, performing a Find, or another procedure that destroys the sort order. A Show All Records step is included to ensure you're working with all the table data, rather than a subset. (When adding Account Type as the first sort field, click Custom order based on value list and select Account Type as the value list.)
Display Record List. This script will be attached to the List button above the Main layout. When clicked, FileMaker will display the Account List layout, ensure that all records are visible, sort them appropriately, and then adjust the window size to display the record list.
View Record. This script will be attached to each View button on the Account List layout. When you click a record's View button, the selected record is shown in the Main layout.
Opening Script. Optionally, you can create a script that runs automatically when a database is opened or closed. The Opening Script ensures that the database is ready to use. It switches to the Main layout, resizes the window, ensures that all records are visible and sorted correctly, and then displays the first record. Later in the chapter, you'll set it as the opening script.
Add Savings Record, Record Stock Dividend, Record CD Interest. Each of these scripts will be attached to a transaction button on the Savings/Money Market, Stock/Mutual Fund, or CD tab panel of the Main layout. When the button is clicked, it will create a new record in the transaction table in which you can record the data. To ensure that the savings account number, stock description, or CD certificate in the transaction table matches the one in Main, a set of Copy and Paste script steps are employed. The Copy step copies the account number, description, or certificate ID from the record in Main; Paste puts the copied data into the matching field in the transaction table.
In preparation for data entry, the cursor is positioned in the Date field. While you're entering the data for the transaction, the script pauses until you click the Continue button. Then you're returned to the Main layout.
Then select the duplicate, click Edit, rename the duplicate, and make the necessary changes to the steps. Repeat this process to create the third transaction script.
Note: The final four steps (Pause/Resume Script, Go to Layout, Adjust Window, and Perform Script) are identical in all three scripts. To save space, these steps are only listed at the end of the Add Savings Record script. Be certain they are present in the other two scripts.
Note: When editing the duplicate scripts, be very careful to specify fields from the correct table. Both Stocks and CD table have an Identifier field, for example.
Savings Report, CD Report, Savings Bond Report. These report scripts are identical; only the options for Steps 24 differ. Create the first script, duplicate it, and edit the options to create the other two scripts. The script starts by finding the records needed for the report, based on the data in Account Type. Then it switches to the report layout, sorts the data, sets the window as large as the screen (Mac) or FileMaker window (PC) allows, and enters Preview mode.
The script then pauses so you can examine the report. If the report has multiple pages, you can view them by clicking pages of the Book icon. If you want to print the report, you can choose the Print Current Report script from the Scripts menu. When you're done viewing the report, click the Continue button in the status area. The script ends by switching back to Browse mode on the Main layout, adjusting the window size, showing all records again, and sorting them.
To create the Find criteria for the second step, add the Perform Find step and click the Specify button. In the Specify Find Requests dialog box, click New.
In the Edit Find Request dialog box, select Account Type from the Find records when list, and type Savings/Money Mkt in the Criteria box.
Click Add to add this as a new criterion. Click OK to close the dialog box, and click OK again to close the Specify Find Requests dialog box.
Stock Report. This report script differs a little from the previous three. Because it must be displayed in landscape mode, it's necessary to add a pair of Print Setup steps. The first sets landscape mode so you can view the full width of the report. The second resets the mode to portrait, ensuring that regardless of what you do next (such as enter new investments, record a transaction, or generate a different report), the screen will have the correct orientation.
Print Current Report. When viewing a report onscreen, you can send it to the printer by running this one-step script. The method of setting options for the Print step depends on whether you're using a Mac or a PC.
When setting options on a Mac, select Copies & Pages from the drop-down list and click the All radio button in the Pages section. Select FileMaker Pro or FileMaker Pro Advanced from the drop-down list, and click the Records being browsed radio button. Click Print to complete the process.
When setting options on a PC, select Records being browsed from the Print drop-down list, and click the All radio button in the Print Range section.
Account Summary Report. Because it uses all records in Main (rather than relying on a Find to select a record subset) and uses the same sort specifications as Main, this script is simpler than the others and requires fewer steps.
Rather than create the script from scratch, it will be quicker to duplicate one of the initial three report scripts and make the necessary changes. Be sure to remove the unnecessary steps.