Auto-Enter Calculations
Calculation fields are fantasticthey save time and ensure error-free results. But they have one serious limitation: You can't change their values. Of course you can adjust the calculation itself, but sometimes a field needs the capacity to override its calculated value on a record-by-record basis.
For example, it would be nice if your invoice's Date Due field automatically showed a date 30 days after the date of the invoice itself. But sometimes you might want to make an invoice due earlier or later, based on special circumstances (like a holiday). If you make the Date Due field a calculation field, you don't have this flexibility. The solution is to use a normal Date field with an Auto-Enter calculation (see box on Section 9.5).
Like all the Auto-Enter options (Section 3.3), an Auto-Enter calculation automatically fills in a field's value, but leaves it changeable. You can get all the accuracy and time savings of a calculation field, plus the power to change your mind. Here's how to put it to use:
- Bring up the Define Database window and switch to the now-familiar Fields tab. From the Table pop-up menu, choose Invoices.
The fields from the Invoices table appear.
- Select the Date Due field in the list and click Options.
The Field Options dialog box makes an appearance.
- On the Auto-Enter tab, turn on the Calculated Value checkbox.
The Specify Calculation window appears. It looks just like it did before, but this time you're not creating a calculation field. Instead, you're specifying the calculation used to determine the auto-enter value.
- Create the calculation Date + 30.
You can use any method you want to build this calculation: Click the field and operators, or type them. Notice that the calculation result is set to Date, and there's no pop-up menu to allow you to change that. Your calculation must resolve to a valid date, or FileMaker will squawk at you.
- Click OK three times to dismiss all the dialog boxes.
You return to the database itself.
Now you can create a new invoice and test out your field. When you enter a Date for the invoice, the Date Due field updates instantly with the date 30 days from now. Notice that you can still change the Date Due field if you want.