Home

Creating a Report

 

Report Design Fundamentals

 

Introduction

So far, we have spent a great deal of time on forms and their design. This was because the users spend most of their time using them. Then comes the time to print data. In Lesson 3, we saw that you could print from a table or a form. The best way to print is through a report and we had a simple introduction in that same lesson. Like a form, a report should be meticulously designed. Unlike forms, some details present a different concern on reports.

As mentioned in previous lessons, a report shares many characteristics with a form. In the Navigation Pane, a report is represented by a green icon Report Icon that you can use to open the report. Like a form, once opened, a report is represented by a tab or a title bar (for an overlapped database) that displays its name. By its definition, a report mimics a piece of paper and therefore it uses a white background.

Like a form, a report can be displayed in different views but the report has more varieties.

A Review of Report Creation

As we saw in Lesson 3, to quickly create a report, in the Navigation Pane, click a table to select it. Then, on the Ribbon, click Create and, in the Reports section, click Report. Another fast way is by using the Report Wizard. To start it, in the Reports section of the Create tab of the Ribbon, you can click the Report Wizard button. This would launch a wizard that you can simply follow (we saw how to use the Report Wizard in Lesson 3).

When it comes to report design, the rules to add and manipulate the controls are the same we reviewed for the form. We studied the techniques of control design in the Lessons 6 and 7. In Lesson 12, we reviewed the common characteristics of database fields. Everything in that lesson is valid for controls positioned on a report. In Lesson 16, we mentioned that, for all of the expressions we learned to create, the techniques and rules were valid for both the forms and the reports.

Practical Learning: Creating a Report

  1. Start Microsoft Access
  2. Open the College Park Auto Repair1 database you started in Lesson 15 and continued in Lesson 21
  3. In the Navigation Pane, under Forms, double-click RepairOrders
  4. Click the New Record button New Record
  5. Create the following record:
       
    College Park Auto Parts
     
    College Park Auto Parts
     
    College Park Auto Parts
     
    College Park Auto Parts
  6. Close the RepairsOrders form
  7. To start a new report, on the Ribbon, click Create
  8. In the Reports section, click Blank Report
  9. Right-click the tab or the title bar of the report and click Save
  10. Set the name to RepairOrders and click OK

Field Insertion on Forms and Reports

Data on fields of forms and reports fall in three main categories: fields that directly originate from a table (or a query), fields created as a combination of existing fields, and fields independent of any other fields. The techniques used to create these fields are different but a field created using one technique can be changed into another category as necessary.

If you want to use a field that is already part of a table (or a query), before or when creating a report, you must specify the list that holds the fields. There are various ways you can do this:

  • If you have already started a report and it is displaying in Design View but you did not yet select the table that holds the list of fields, in the Property Sheet for the report, you can click the arrow of the Record Source field and select the table from the list
  • If you want to use only a selected list of fields from a table, start the report in Design View without selecting an object. Then, in the Property Sheet, click the Record Source field and click its ellipsis button. This will allow you to use the Query Builder to create a query that is a list of the needed fields. After creating the query, close it. Its Field List would display only the previously selected fields

To add a field to a report, you can either click a control from the Ribbon and click the report, or drag a field from the Field List to the report.

The Views of a Report

 

 The Design View

One of the ways you can display a report is called the Design View. As seen in previous lessons, to display a report in Design View

  • From the Navigation Pane, you can right-click the report and click Design View
  • If the report is already opened, in the Views section of the Ribbon, you can click the arrow button under View and click Design View
  • If the report is already opened, you can right-click its tab or its title bar and click Design View

As done for a form, in the Design View of a report, you can add, position, format, configure, and manipulate the necessary controls. The Design View is equipped with one or more sections. The primary sections are the Page Header, the Detail, and the Page Footer:

Design View

As mentioned when studying form and report design, when a report is in Design View, the Ribbon is equipped with a Controls section in its Design tab. You can use those controls to populate your report. You can also select objects from the Field List and add them to the report.

The Print Preview

To have an idea of what a report would look like on a printed piece of paper, you can display it in what is referred to as Print Preview. To do this:

  • If you have created a report using the Report Wizard, it would automatically display in Print Preview
  • In the Navigation Pane, you can right-click a report and click Print Preview
  • If the report is already opened, you can right-click its tab or its title bar and click Print Preview

When a report appears in Print Preview, the Ribbon is made of only one tab.

To appear realistic, a report in print preview appears as a piece of paper with margins. Its body is filled with the data that would be printed. Here is an example:

Report Print Preview

The right side and the bottom-right side display a scroll bar each. Like a form in Form View, the Print Preview of a report may be equipped with navigation buttons. The functionality of these navigation buttons is as we described for a table.

After using the Print Preview, to close it, in the Close Preview section of the Ribbon, you can click the Close Print Preview button Close Print Preview. This would display the report in the view it previously had.

Practical Learning: Using the Print Preview of a Report

  • Right-click the title bar of the report and click Print Preview

The Report View

The Report View shows a report with its controls and the items in its sections but it does not show the margins:

The Report View

Unlike the Print Preview, the Report View does not distinguish where a section starts and where it ends.

The Layout View

The Layout View of a report appears as a drawing board. It shows its title bar and its system buttons. In its body, it displays three dotted lines that represent the top section and the margins:

Layout View

Like a Design View, you can use the Layout View to add and manipulate controls on a report.

The Sections of a Report

 

The Page Header and the Page Footer Sections

When a piece of paper prints, it is made of a top section, a body, and a bottom section. To support this, a report can be equipped with a Page Header that represents the top part, a Detail section that represents the body of the report, and a Page Footer section that represents the bottom part.

If you create a report using either the Blank Report or the Report Design options of the Reports section of the Ribbon, the report would be equipped with a Page Header and a Page Footer sections:

A report equipped with the Page Footer, the Detail, and the Page Footer sections

If you have a report that doesn't have these sections and you want to add them, right-click the report and click Page Header/Footer Page Header/Footer

As mentioned previously, the Page Header represents the top section of the printed paper. Therefore, when designing a report, put in the Page Header the objects you want to display on each top part of the printed paper. For example, you can put the common title or the page number in that section. That section is also typically used to display the title of a brochure or book.

Because the Page Footer represents the bottom part of each printed page, you can put on it the object(s) that would display on each page. For example, you can use it to display the date the report is being printed.

Practical Learning: Using the Page Header of a Report

  1. To change the view of the report, right-click its title bar and click Design View
  2. Notice that the report is equipped with a Page Header and Page Footer sections.
    On the Ribbon, click Design if necessary.
    From the Controls section, click Label and click under the Page Header bar in the left section (no precision necessary)
  3. Type College Park Auto Repair and press Enter

The Detail Section

Like a form, to show the sections of a report, it must be opened in Design View. Like a form, the most fundamental part of a report is the Detail section, which holds the most controls of a report. In fact, a report can have only that section. If you create a report using one of the options from the Reports section of the Create tab of the Ribbon, the report would come equipped with various sections. To have only the Detail section, you can right-click the report and click the option of those sections to remove them. You may end up with only the Detail section:

The Detail section of a report

You can then equip it with the desired controls.

The Size of a Report

Like a form, a report has a size, which is the combination of its width and its height. When it comes to the height, each section has and controls its own vertical measure. As done for a form, to specify the height of a section:

  • You can drag up or down the bottom border of the bar of the next section
     
    Resizing the sections of a report
  • You can access the Property Sheet of that section and change the value of the Height property

As seen for a form, the height that a report displays in Design View is the total height of its sections.

When it comes to the width of a report, all sections use the same measure. The width that a report shows in Design View is the common width of its sections. Therefore, to specify the width of a report:

  • You can drag left or right the right border of any section
     
    Resizing a report
  • You can access the Property Sheet of the form and change the value of the Width property

To change both the height and the width of the report: 

  • You can drag left, up, right, or down the bottom-right corner of the lowest section
     
    Resizing a report
  • You can access the Property Sheet of the report then change the values of both the Height and the Width fields

Practical Learning: Using the Detail Section of a Report

  1. Double-click the button at the intersection of the rulers The button at the intersection of the rulers to access the Property Sheet
  2. In the Property Sheet, click the Data tab, click Control Source, type r and press Enter to select RepairOrders
  3. Design the report as follows:
     
    College Park Auto Parts
     
    College Park Auto Parts
  4. Save the report
  5. Right-click its title bar and click Print Preview
    College Park Auto Parts
    College Park Auto Parts
  6. Close the report

The Report Header and the Report Footer

As mentioned already, the report is the primary object used to print the data of a database. You may have created a database that represents many objects sold in a store or you could have created a database for a list of people such as the students of a high school. In these cases, you may want to create a report that shows the list. To print a realistic book, a magazine, or a brochure, you would want to have a front cover and a back page.

To support the cover and the back page, the report can be equipped with two other sections: The Report Header and the Report Footer sections:

A report equipped with the Report Footer, the Detail, and the Report Footer sections

If you create a report using either the Report or the Report Wizard options of the Reports section of the Ribbon, the report would be equipped with a Report Header and a Report Footer sections. If you have a report that doesn't have these sections and you want to add them, right-click the report and click Report Header/Footer Report Header/Footer.

As seen in the above screenshot, you can have a report that has a Report Header and a Report Footer sections without the Page Header and the Page Footer sections. If you have a Page Header and the Page Footer sections but don't want to show them on a printed paper, you can completely reduce their heights:

A report equipped with all sections

Otherwise, if you are creating a book or brochure that would represent a list of various items, you should equip it with all these five sections.

When to Display a Section

By default, after adding a section to a report, the section would show in Design View and its contents would appear in the other views. If you want, you can hide the section in either the Design View or the other views. This characteristic is controlled by the Display When enumerated property. To apply it, display the report in Design View and access the Property Sheet of the section on which you want to control this characteristic. Click either the Format or the All tab.

The Display When property has three options:

  • Always: This is the default value of the property. It indicates that the section will display in Design View and its contents would appear in all views
  • Print Only: The section will appear in Design View and Print Preview only, not in Report View or Layout View
     
    Display When
    Report View
    Report View: Display When - Print Only
    Print Preview
    Print Preview: Display When - Print Only
  • Screen Only: The section will appear in Design View, in Report View, and in Layout View, but not in Print Preview
 
   
 

Printing a Report

 

Introduction

After creating a report, you have many options to print it. The fastest option consists of sending the report directly to the printer. To do this:

  • In the Navigation Pane, right-click the report and click Print...
  • Click File and click Print. This would display a window with three options:

Print

To send the document directly to the printer, click Quick Print.

Practical Learning: Printing the Records

  1. In the Navifation Pane, under Forms, right-click RepairOrders and click Design View
  2. In the Controls section of the Ribbon, click the More button More. Make sure the Control Wizard button is on Use Control Wizard. If not, click it.
    In the Controls section of the Ribbon, click the Button Button and click under the Form Footer bar on the left side of the Close button
  3. In the first page of the wizard, in the left list, click Report Operations
  4. In the right list, click Print Report
     
    Command Button Wizard
  5. Click Next
  6. In the second page of the wizard, make sure the RepairOrders report is selected and click Next
  7. Click Print Record and change it to Print all Records
     
    Command Button Wizard
  8. Click Next
  9. Change the name of the button to cmdPrintAllRecords
  10. Click Finish
  11. Right-click the title bar of the form and click Form View
  12. Click the New Record button New Record
  13. Create the following record:
       
    College Park Auto Parts
     
    College Park Auto Parts
     
    College Park Auto Parts
     
    College Park Auto Parts
  14. Click the Print all Records button
  15. If you have a printer (or your computer is connected to a printer), click Print.
    If you don't have access to a printer, click Cancel
  16. Right-click the title bar of the form and click Design View

The Print Dialog Box

The Print dialog box is the most regular object used to send a document to the printer. To display it:

  • Click File and click Print. In the window that appears, click Print
  • Use the Print Preview:
    • In the Navigation Pane, right-click a report and click Print Preview
    • In the Navigation Pane, double-click a report to open it. Right-click the title bar or the tab of the report and click Print Preview
    In the Print section, click the Print button

If a report contains many records:

  • To print all of them, in the Print dialog box, accept or click the All button
  • To print a specific record, click the From text box and type number of the record
  • To print a range of records, click the From box, type the starting range. Click the To text box and type the end number of the range

Printing a Specific Record

In a transaction-based application, a user usually wants to print the record he or she is viewing from a form. You can easily do this using a macro. When creating the macro, you have to specify the condition by which the record would be selected.

To proceed, start a normal macro:

  • In the Add New Action combo box, select Open Report
  • In the Action Catalog window, expand Actions and expand Database Objects. Drag OpenReport and drop in the left window

You must specify the name of the report in the Report Name combo box. To create the condition that specifies how to locate the record to print, you can manually write an expession or use the Expression Builder to create it.

Practical Learning: Printing a Record

  1. In the Controls section of the Ribbon, click the Button Button.
    If the wizard comes up, click Cancel
  2. In the Property Sheet, click All and change the following characteristics for the button
    Name: cmdPrintInvoice
    Caption: Print Invoice
  3. Click the Event tab
  4. Click On Click, then click its ellipsis button
  5. In the Choose Builder dialog box, click Macro Builder and click OK
  6. Click the arrow of the Add New Action combo box and select OpenReport
  7. Click the arrow of the Report Name combo box and select RepairOrders
  8. Click the arrow of the View combo box and  select PrintPreview
  9. In the Where Condition text box, type ="[AutoRepairID] = " & [AutoRepairID] (this expression means "Find the record where the AutoRepairID (on the report) is equal to the current AutoRepairID (on this form")
     
    Macro to Print
  10. On the Ribbon, click the Close button
  11. When asked whether you want to save the macro, click Yes window
  12. Right-click the title bar of the form and click Form View
  13. Click the Close button to close the form
  14. When asked whether you want to save, click Yes
  15. In the Navigation Pane, under Forms, double-click RepairOrders
  16. Navigate to the second record
  17. Click the Print Invoice
  18. If you have a printer (or your computer is connected to a printer), on the Ribbon, click Print. On the Print dialog box, click Print.
    If you don't have access to a printer, click Cancel
  19. Click the Close button to close the form

Lesson Summary

 

MCAS: Using Microsoft Office Access 2007 Topics

C6 Create reports
 

Exercises

 

Yugo National Bank

  1. Open the Yugo National Bank1 database
  2. Create a (columnar) report for the Employees table. Save it as Employees and design it as you see fit
  3. Create a (columnar) report for the Customers table. Save it as Customers and design it as you see fit

Watts A Loan

  1. Open the Watts A Loan1 database
  2. Create a (columnar) report for the Employees table. Save it as Employees and design it as you see fit
     
    Employees
  3. Create a (columnar) report for the Customers table. Save it as Customers and design it as you see fit
     
    Customers
 
 
   
 

Previous Copyright © 2010-2012 FunctionX Next