When you design a layout, you usually include all fields that might be needed, even if some arent always used. Major changes are best handled by creating another layout, but there can be times when you only need to include (or exclude) a specific field. For instance, you might have designed an invoice layout that includes a discount field. You would only want that field and its label to appear if there is a discount. (Otherwise the customer will want to know why they didnt get one.) By creating a calculated field that contains both the value and the label, you can customize the layout to automatically display or hide the field.
1 .Choose File > Define > Database (Control+Shift+D/Command+Shift+D).
2 .When the Define Database dialog box appears, click the Fields tab.
3 .Type a name into the Field Name text box. Choose Calculation as the Type, and click Create (Figure 3.54).
4 .When the Specify Calculation dialog box appears, in the functions list on the right double-click If (Figure 3.55).
5 .In the Discount Display area, replace "test" in the If calculation by double-clicking it to make it the only highlighted parameter, then double-click IsEmpty in the Functions list.
6 .With "field" highlighted in the calculation, double-click the field you want to designate in the fields list on the left side. This example uses the Discount field (Figure 3.56).
7 .Double-click the parameter "resultOne" to select it, then click the quotes button in the Operators keypad (Figure 3.57).
8 .Double-click the parameter "resultTwo" to select it, then click the quotes operator button again. Type the name of your label and a space between the trailing quotation mark. In this example, the label is "Discount" (Figure 3.58).
9 .Move your cursor between the last quotation mark and parenthesis and click the ampersand (&) operator button. Add the GetAsText function by double-clicking it in the right functions list.
10 .With "data" highlighted in the calculation, double-click the same field you chose in step 5. This example uses the Discount field.
11 .Move your cursor between the two closing parentheses. Click the ampersand button, then the quotes button, and type % between the quotes.
12 .Make sure to choose Text from the "Calculation result is" pull-down menu, and click OK (Figure 3.59). When youre finished, click OK to close the dialog box.
13 .Go to the layout where the new field will be displayed and switch to Layout mode (Control+L/Command+L).
14 .Add the new field to the layout.