Creating a Report from Scratch

Creating a Report from Scratch

When you want to create a report that displays records from one or more tables, the Report Wizard is the fastest way to create the report and include all the desired field captions and contents. However, sometimes a main report simply serves as a shell for one or more subreports, and the main report displays little or no information from the underlying tables. In this case, it is often easier to create the main report by hand in Design view.

In this exercise, you will use a query as the basis for the shell for a report that lists sales by category. A CategoryName section will list the current category, but the Page Header, Detail, and Page Footer sections will contain no information.

USE the GardenCo database in the practice file folder for this topic. This practice file is located in the My DocumentsMicrosoft PressAccess 2003 SBSReportsByDesign folder and can also be accessed by clicking Start/All Programs/Microsoft Press/Access 2003 Step by Step.

OPEN the GardenCo database and acknowledge the safety warning, if necessary.

  1. On the Objects bar, click Queries.

  2. Click Sales by Category to select it.

  3. On the Insert menu, click Report.

  4. Double-click Design View to open a blank report.

    Tip

    The Page Header, Detail, and Page Footer sections you see in Design view are the default sections for a new report, but you don’t have to use them all, and you can add others.

    A small window also opens, displaying a list of the fields in the Sales by Category query.

  5. On the View menu, click Report Header/Footer.

    The sections are now enclosed in the Report Header and Report Footer sections.

    Troubleshooting

    If the page header and footer disappear from your report, on the View menu, click Page/Header/Footer to restore them, and then click Report Header/Footer.

  6. On the View menu, click Sorting and Grouping.

    The Sorting and Grouping dialog box appears, in which you can specify the fields that will be used to group the records in the report.

  7. Click the down-arrow to the right of the Field/Expression box, and click CategoryName.

  8. In the Group Properties area, set Group Header to Yes.

    An icon appears in the selector button to the left of CategoryName to indicate that it is a group heading, and the CategoryName Header section selector appears in the Design view window.

  9. Close the Sorting and Grouping dialog box.

  10. Click the Report selector in the upper-left corner of the report, and then press to open the Properties dialog box.

    Tip

    If the report is already selected, the Report selector has a small black square in it.

  11. In the Properties dialog box, click the Format tab, and scroll down until you see the Grid X and Grid Y properties. Set them each to 10.

    The grid, which is represented by dots in the report background, becomes easier to use when aligning controls.

  12. On the Format tab, set the height of each section by clicking the section selector and then setting the Height property as follows:

    Section

    Setting

    Report Header

    1″

    Page Header

    0″

    Category/Name Header

    2.2″

    Detail

    0″

    Page Footer

    0.2″

    Report Footer

    0″

    Tip

    You can also set the height of a section by dragging the top of the section selector up or down.

  13. Move the Properties dialog box to view the results. (Resize the window to see all sections, if necessary.)

    Tip
  14. Click the Save button, type Sales by Category as the name of the report, and then click OK.

    Tip
  15. If the toolbox isn’t displayed, click the Toolbox button on the toolbar.

    Tip

    The toolbox is now displayed.

  16. To give the report a title, click the Label control in the toolbox, and then click the top of the Report Header section, about 2 inches from the left edge.

    Tip

    Access inserts a very narrow label.

  17. Type Sales by Category, and press .

    The label expands to hold the text you type, and when you press , Access selects the label control and displays its properties in the Properties dialog box.

  18. Scroll down, and set the label’s font properties as follows:

    Property

    Setting

    Font Name

    Times New Roman

    Font Size

    20

    Font Weight

    Bold

    Font Italic

    Yes

    The text in the label reflects each change. By the time you finish making all the changes, the text has outgrown its frame.

  19. On the Format menu, point to Size, and then click To Fit.

    Troubleshooting

    After the focus leaves this control, Access displays an error warning that the new label is not associated with a control. Click the icon to display a shortcut menu, and then click Ignore Error.

  20. On the Insert menu, click Date and Time to display the Date and Time dialog box.

    Troubleshooting
  21. Make sure that Include Date and the first (long) date format are selected, clear the Include Time check box, and click OK.

    A text box containing =Date() appears in the upper-left corner of the Report Header section. If the report has no Report Header section, the text box appears in the Detail section.

  22. Drag the new text box containing =Date() below the title, adjust the width of the box to match the width of the title, and click the Center button on the Formatting toolbar to center the date in the box.

    Troubleshooting
  23. Drag the CategoryName field from the field list window to the top of the CategoryName Header section. (You might have to scroll up to see this field.)

  24. Delete the Category Name label that was inserted with the text box.

  25. Select the text box, and set its font properties to the same settings as those used for the report title, in step 18.

  26. On the Format menu, point to Size, and then click To Fit.

  27. Position the text box with its top against the top of the section and its left edge 0.2 inch (two dots) in from the left, and then drag the right edge of the text box to about the 2.4-inch mark.

  28. Click the Save button to save the report, and then display it in Print Preview.

    Troubleshooting
  29. Return to Design view, and add a label below CategoryName. Click the Label button in the toolbox, click directly below the left edge of the text box, type Product:, and then press .

    Because this label is not associated with a control, you will see another error. Click the icon, and then click Ignore Error.

  30. Set the font properties that you set for CategoryName in step 25, except for Font Size, which should be 12.

  31. Right-click the label, point to Size on the shortcut menu, and then click To Fit.

  32. Position the label at the bottom of the CategoryName text box, aligning their left edges.

  33. Insert a page number in the Page Footer section by clicking Page Numbers on the Insert menu to display the Page Numbers dialog box.

    Troubleshooting
  34. In the Format area, select the Page N of M option; and in the Position area, select the Bottom of Page [Footer] option. Click the down arrow to the right of the Alignment box, and click Center. Then click OK.

    Access centers a text box containing the expression = "Page" & [Page] & "of" & [Pages] in the Page Footer section.

  35. Save the report, and then preview the results.

  36. Close the report.

CLOSE the GardenCo database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.169.78