Lesson 7.13. Creating a Calculated ControlFigure 7-20. To enter database fields in an expression, type the field name in brackets.Figure 7-21. If a database field name exists in more than one table, you will need to enter the name of the table that contains the field in brackets, followed by an exclamation mark (!).Figure 7-22. You create a calculated field by entering an expression in the Control Source box.A calculated control is an unbound control that displays totals and other arithmetic computations on a form. You create calculated controls by entering an expression (or formula) to perform the calculation in the control's Control Source property. In forms, expressions start with the equal sign (=), which tells Access that you want to perform a calculation. After the equal sign, you must specify two more types of information: the values you want to calculate and the arithmetic operator(s) or function name(s) you want to use to calculate the values. Expressions can contain explicit values, such as the numbers "4" or "5" or can reference the values contained in database fields. For example, the formula =[Cost]*[Commission] would multiply the values in the Cost and Commissions fields. To enter fields in an expression, type the field name in brackets ([Order Total]), as shown in Figure 7-20. If a field name exists in more than one table, you will need to enter the name of the table that contains the field in brackets ([Customer Tours]) followed by an exclamation mark (!) and then the field, such as [Order Total], as shown in Figure 7-21.
Although you worked on a form in this lesson, you can also use expressions to create calculated controls and fields in queries and reports.
|