Reports are often used just to display data. For example, it might be enough that an inventory report displays the in-stock, reorder level and on-order values for all a company's products. But anyone who uses a report as part of a decision-making process probably wants more than mere data. Such a person likely also needs to analyze the data in some way, and most data analysis requires one or more calculations. What were the total sales last quarter? How many days overdue are the unpaid invoices? How many records are in this report? To answer these and many other questions within a report, you need to add one or more calculations. In the report Design view, you add calculations by adding text boxes, which you can use as unbound controls that display calculated results. Here are the steps to follow to create a calculated text box control:
For example, the report in Figure 4.37 contains a number of calculated text box controls. Figure 4.37. To create a calculated control, enter an expression into an unbound text box (or into its Control Source property).Two of the controls deal with the report grouping. The first, in the group header section (named UnitPrice Header in the figure), uses the following expression: ="Unit Prices from " & Min(FormatCurrency([UnitPrice])) & " to " & Max(FormatCurrency([UnitPrice])) Because this control resides in the group header, the expression applies only to those records in each grouping. In this case, the expression uses the Min and Max functions to specify the range of values within each group. The second grouping-related calculated text box control in Figure 4.37 is in the group footer section (named UnitPrice Footer in the figure); it uses the following expression: ="Total Number of Records in Group: " & Count([UnitPrice]) This expression uses the Count function to display the number of records in the group. The report in Figure 4.37 also includes two calculated text box controls in the Page Footer section. The text box on the left displays the current date and time using the following expression: =Now() On the right of the page footer, a text box displays page number data using the following expression: ="Page " & [Page] & " of " & [Pages] Here the [Page] identifier displays the current page number, and the [Pages] identifier displays the total number of pages in the report. Figure 4.38 shows a preview of the report. Figure 4.38. The preview of the form shown in Figure 4.37. |