Share this Page URL

Chapter 10. Presenting Data with Reports > Working with a Report in Design View - Pg. 349

Presenting Data with Reports 15. 16. 349 If the Properties dialog box isn't open, right-click the text box for UnitPrice, and then click Properties. On the Other tab, enter txtRevenue in the Name property. When you add a bound control to a report (or a form), Access uses the name of the field as the control's name. If you're using standard prefixes or another naming convention, you should name every control you include so that it follows the convention. If the name of a control uses the same name as a field, you'll receive an error if you use the name of the control in an expression that refers to the field. Because we'll be using the Uni- tPrice field in an expression in this text box, we have to give the control a name that's different from the name of the field. Otherwise, we'll have a circular reference error. If you're viewing data in a report or a form and see #Error where you expect to see the results of a calculation, check to be sure you haven't created a circular reference. Click the Data tab. In the Control Source property box, enter the expression =Sum([Uni- tPrice]*[Quantity]), or click the Build button to open the Expression Builder to create this ex- pression. On the Format tab of the Properties dialog box, set the Format property to Currency. Using the toolbox, add a text box to the Country Footer section. Position the text box so that it's aligned under the Revenue label. Delete the label that Access provides (if you haven't set the Auto Label property to No). Enter the expression =Sum([UnitPrice]*[Quantity]) in the text box, and then set the Format property for the text box to Currency. Add a second text box to the Country Footer section, positioning the text box to the left of the one we added in step 19. Delete the label for this text box as well. In the text box, enter the expression ="Total for " & [Country]. We're using the second text box as a label. The expression you entered will display Total for and the name of the country for which data is displayed. Click the View button to open the report in the Preview window. You'll see a single entry for each product, the quantity and revenue for each product, and a sum of the revenue for each country, as shown here: 17. 18. 19. 20. 21. 22. Inserting a page break You can insert a hard page break in a report by using the Page Break tool in the toolbox. You might want to insert a page break after a title page or before printing a summary page in a report.