Report Design Fundamentals
You can print data using a table or a form, but the favorite object to print records is the report. As mentioned in previous lessons, a report shares many characteristics with a form. Still, just like forms have some particular characteristcs, some aspects are uniques to reports.
Practical Learning: Introducing Reports
Introduction to Report Creation
As we saw in Lesson 6, to quickly create a report, in the Navigation Pane, click a table to select it. Then, on the Ribbon, click Create. 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, click the Report Wizard button. This would launch a wizard that you can simply follow (we already saw how to use the Report Wizard in Lesson 3).
To start a report as blank piece of paper, on the Ribbon click Create. In the Reports section, click the Blank Report button. To create the types of labels that are sometimes glued on an envelop or a paper folder, click the Labels button on the Ribbon.
Opening a Report
Like a form, a report can be displayed in different views but the report has more varieties. If a report exists already, in the Navigation Pane, it is represented by a green icon followed by the name of the report. The regular display of a report is called the Report View. To open a report whether it is currently closed or opened in a different view:
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 is presented like a piece of paper. Therefore it uses a white background.
Introduction to Report Design
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 from Lessons 6 and subsequent lessons. Although some of the issues concerned only forms, most of what involves design is the same for forms and reports.
Practical Learning: Starting a Report
Field Insertion on Forms and Reports
Data on the controls of a form or report falls in three main categories: fields that directly originate from a table, an expression created as a combination of existing fields, and values independent of any field. Before or when creating a report, you can specify the table that holds the records. 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 records, in the Data or the All tab of the Property Sheet of the report, click the arrow of the Record Source field and select the table from the list.
Practical Learning: Introducing Report Design
The Views of a Report
The Design View
To design a report, you must display it in Design View. To do this:
Here is an example of a(n empty) report in 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. Of course, you can also select objects from the Field List and add them to the report.
Practical Learning: Using the Design View of a Report
The Print Preview
A good way to see what a printed report would look like is to preview it. Such a view is referred to as Print Preview. To preview a report:
When a report appears in Print Preview, the Ribbon is made of only one tab:
To appear realistic, a report in print preview appears like a piece of paper with margins. Its body is filled with the data that would be printed. Here is an example:
The right side and the bottom-right side may display a scroll bar each. Like a form in regular Form View, the Print Preview of a report is equipped with navigation buttons. The functionality of these navigation buttons is as we described for a table or form.
After using the Print Preview, to close it, in the Close Preview section of the Ribbon, click the Close Print Preview button . This would display the report in the view it previously had.
Practical Learning: Checking the Print Preview of a Report
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:
To open a report in the Report View:
Unlike the Print Preview, the Report View does not distinguish where a section starts and where it ends.
Practical Learning: Seeing the Report View
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:
Like a Design View, you can use the Layout View to add and manipulate controls on a report.
Practical Learning: Seeing the Layout of a Report
The Sections of a Report
The Page Header and the Page Footer Sections
As seen for a form, the Design View of a report can be equipped with one or more sections. By default, the primary section is the Page Header. The page header is equivalent to the top section of a printeg piece of paper.
If you create a report using either the Blank Report or the Report Design options of the Reports section of the Ribbon, the report is automatically equipped with a Page Header sections.
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 or text 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.
The Detail Section
Like a form, the most fundamental part of a report is the Detail section. It 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 the sections to remove. You may end up with only the Detail section:
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:
As seen for a form, the height 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 a report shows in Design View is the common width of its sections. Therefore, to specify the width of a report:
To change both the height and the width of the report:
As seen for a form, you can specify any width youo want for a report, but this aspect is subject to the printer. Therefore, the width of a report should equal or narrower than a piece of paper (11" x 8.5"). If you set a width that is too high, Microsoft Access would warn you by displaying a green rectangle on the button at the intersection of the rulers:
Of course, the solution is to narrow the body of the report (to somewhere around Measure 8 of the horizontal ruler).
Practical Learning: Using the Detail Section of a Report
The Page Footer Section
A report can be equipped with a Page Footer. It represents the bottom part of a printed piece of paper. If you create a report using either the Blank Report or the Report Design button of the Ribbon, the report would automatically be equipped with a Page Footer section besides the Page Header side:
If you have a report that doesn't have these sections and you want to add them, right-click the report in Design View and click Page Header/Footer
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.
The Report Header
To create a book, a magazine, or a brochure, you may want to have a front cover. Such a section is handled by the Report Header section.
The Report Footer
If you are creating a report that should appear with many pages you may want the last page to have specific information or a particular design. To support thise, the report can be equipped with a Report Footer section. Normally, the Report Header and the Report Footer sections are added together:
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 in Design View and click 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:
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.
Reports and Windows Controls
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:
Some controls are not available for the report because such controls don't have any role in a report. An example is the Web Browser. Some other controls are available but you should really decide if you need them and why. Examples are the buttons (the Button and the Toggle Button) and the Attachment. Other than that, you can use the controls from the Ribbon to populate your report.
Practical Learning: Using the Page Header of a Report
If you want to show the current date and/or time on a report, use the Date and Time control from the Controls section of the Ribbon. We reviewed in Lesson 14 how to use it.
Practical Learning: Displaying DateTime on a Form
In a report meant to display various records on its many pages, you may want to display the page number. To do this, in the Controls section of the Design tab of the Ribbon, click Page Numbers and click the report. The Page Numbers dialog box would come up. Use the Page Numbers dialog box to specify what sentence would be used, and where, to display the page number. Once you are ready, click OK. The new label would be added to the Page Footer section of the report.
Practical Learning: Showing the Page Number on a Report
Unlike a form, a report is primarily considered in a tabular layout. This is because a report is primarily equipped with Page Header section. If you position some controls, such as labels, on it, and add the necessary controls, such as text boxes and combo boxes, in the Detail section, the report would behave like a tabular form, that is, a continuous view of records. You can use this feature of reports to create a tabular report without having to configure it in the Property Sheet, as done form the form.
Probably the easiest way to create a tabular report is to use the Report Wizard. If you start the wizard, in its fourth page, the Tabular layout is selected by default. When you end the wizard, the labels would be automatically positioned in the Page Header section and the text boxes would be added to the Detail section.
As you may know already, a sub-report is just a smaller version of a report, except that a sub-report is made to be displayed in the body of a report. And as you may know already, a sub-report is created in a tabular layout. The easiest way to create a report and its sub-report is by using the Report Wizard. Otherwise, you can create and design your sub-report any way you like.
When designing a sub-report, the controls that will be displayed on top should be positioned in the Report Header section. Then you can either completely shrink the Page Header and the Page Footer sections or you can remove them.
After creating a sub-report, you can add it to a report. Remember that, as seen for sub-forms, both the report and the sub-report must hold a relationship in which the report has a primary key field and the sub-report has the equivalent foreign key.
Practical Learning: Creating and Using a Sub-Report
Printing a Report
After creating a report, you have many ways to print it. The fastest option consists of sending the report directly to the printer. To do this:
To send the document directly to the printer, click Quick Print.
To make it easy for users to print a report, you can add a button on a form so that the user can click that button to initiate printing. probably the best way to do this is to use the Command Button Wizard to create the button.
Practical Learning: Printing the Records
The Print Dialog Box
The Print dialog box is the most regular object used to send a document to the printer. To display it:
Any of these actions would display the Print dialog box:
If a report contains many records:
After making the selection, click OK on the Print dialog box.
Practical Learning: Printing the Records
Printing a Specific Record
In a transaction-based application, a user usually wants to print only the record he or she is viewing from a form. You can assist the user with 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:
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, write an expession or use the Expression Builder to create it.
Practical Learning: Printing a Record