Reports are an effective way of creating a printed copy of information taken from data in your database.
|
Although you can also print a query of a form, reports have two main advantages.
|
They can compare, summarize, and subtotal large sets of data.
|
Using a report also gives you greater control over exactly where data prints on a page.
|
Most of the information in a report comes from an underlying table, query, or SQL statement.
|
Other information, such as additional comments or explanations, is stored in the report's design.
|
For example, you might design a report to include the name of the person who created it.
|
Reports have three views
ò Design View
ò Print Preview
ò Layout Preview
|
Design view is used when you want to create a report, or change the structure of an existing report.
|
You can use Print Preview to see the report's data as it will appear on every printed page.
|
Layout Preview is a quick way of checking the layout of a report because Microsoft Access uses just enough data from the underlying table or query to show you what the report will look like.
|
Let's take a look at an existing report in the three views.
|
First you click the ^UReports^u tab, and choose ^UCustomers^u.
|
Then you click the ^UPreview^u button to preview the report.
|
As you can see, the report is magnified so that you can clearly read the data.
|
The magnifying glass pointer means that you can alter perspective.
|
For example, you can zoom out to see how the data is laid out on the whole page.
|
In Access 97, you have the option of displaying more than one page at a time.
|
To display multiple pages you simply click the ^UMultiple Pages^u button.
|
You choose the number of pages you'd like to see.
|
Access displays the pages you've chosen.
|
Let's see what the report looks like in Design view.
|
Like forms, reports are divided into sections.
|
The report header appears once, at the beginning of a report.
|
You can use it for items such as a logo, report title, or print date.
|
The report header is printed before the page header on the first page of the report.
|
The page header appears at the top of every page in the report.
|
You use it to display items such as column and page titles.
|
The detail section contains the main body of a report's data.
|
This section appears for each record in the report's source data.
|
The page footer appears at the bottom of every page in the report.
|
You use it to display items such as page numbers.
|
The report footer appears once at the end of the report.
|
It can display items such as Grand Totals or Total Amount Outstanding.
|
The report footer is the last section in the report design but appears before the page footer on the last page of the printed report.
|
You can hide or view the headers and footers in your report by selecting ^UView - Page Header/Footer.
|
The Layout Preview shows the report's layout.
|
It includes just a sample of the data in the report.
|
Access enables you to separate records into groups.
|
By grouping records meaningfully, you can make a report easier to read.
|
For example, a report that groups customers by region is often easier to understand than one that lists them in random order.
|
The advantage is that you can skim the report to find those customers living in a particular city quickly.
|
When you group records, you can also perform calculations on the data in each group.
|
For example, you could calculate the total value of sales for the group.
@@
There are a number of ways of creating reports in Access.
|
You cannot create a report if you don't have a default printer installed.
|
Suppose you need a sales report to take to a meeting starting shortly.
|
You can create that report quickly using the AutoReport facility.
|
You click the ^UNew Object^u button.
|
You choose ^UReport^u from the drop-down list box.
|
In the New Report dialog box, you can choose one of the AutoReport wizards.
|
The ^UAutoReport: Tabular^u option puts the fields in each record on one line, and prints the labels once at the top of each page.
|
In this case you select ^UAutoReport: Columnar^u, so that each field will appear on a separate line with a label to its left.
|
You click the table or query that contains the data on which you want to base your report, for example ^USales^u.
|
Then you click ^UOK^u.
|
Access applies the last autoformat you used to the report.
|
If you haven't created a report with a wizard before or used the ^UAutoFormat^u command, the default autoformat is used.
|
Suppose you have the Employees table open.
|
You can create a single-column report based on the table by clicking the down-pointing arrow next to the ^UNew Object^u button.
|
Reports created with this method have no report header and footer, only a detail section.
|
Suppose that you need a detailed report to present your product range to prospective clients.
|
The easiest way to do this is to use the Report Wizard.
|
You click the ^UNew Object^u button, and select ^UReport^u in the drop-down list.
|
You click ^UReport Wizard^u.
|
You open the drop-down list box to choose the table on which you want to base the report - here it is ^UProducts^u.
|
Then you click ^UOK^u.
|
In the Table/Queries drop-down list box you can opt to change the table or query on which you based the report.
|
You can also choose to base the report on more than one table.
|
In the Available Fields list box, you can double-click those fields you want to appear on your form.
|
Here, you click the double right arrow to select all the fields.
|
Then you click ^UNext^u.
|
You can now decide how you want to group your fields.
|
For example, you might want to group the report by Category ID.
|
This means that the group header, Category, will introduce the group.
|
The ^UGrouping Option^u button enables you to choose at what intervals you'd like to group the fields.
|
You click ^UNext^u.
|
You can now specify sorting options.
|
For example, you might want to sort the product names alphabetically within a group.
|
In the drop-down list box you choose ^UName^u.
|
The ^USort^u button shows that the product names will be sorted in alphabetical order.
|
You click the ^USummary Options^u button to display data fields that can be summarized.
|
Here, only the Unit Price and Delivery fields can be summarized.
|
Since there has been a change in the Unit Price of various products, you select the ^UAvg^u checkbox.
|
Then you click ^UOK^u.
|
And you click ^UNext^u.
|
Access makes it easy to lay out your report by providing a variety of built-in layouts.
|
You can choose to print your report in the ^UStepped^u option, for example.
|
You can opt to print your pages in landscape or portrait orientation.
|
Here, you choose ^UPortrait^u.
|
If you'd like all your fields to fit on one page, you select the ^UAdjust the ... page^u checkbox.
|
Then you click ^UNext^u.
|
You can scroll through different options to choose a style for your report.
|
For example, you can select the ^UCasual^u option.
|
Then you click ^UNext^u.
|
Although the Report wizard suggests the name Products, here you decide to change the name to "Stock Report".
|
Then you click ^UFinish^u to close the dialog box.
|
The Report Wizard creates your report.
@@
Once your report has been created by a Report Wizard, you can still customize it to suit your business needs.
|
For example, you may want to update your report to display a recently added field from the report's record source.
|
You click the ^UField List^u button to display a list of all the fields in the record source.
|
Then you simply drag and drop the additional field you need on the report.
|
Access draws the new control.
|
When you created the Stock Report, you grouped the products by category, and then sorted them alphabetically.
|
Now, you might decide to change the sort order so that Access sorts the groups by the Unit Price field, and in descending order.
|
You click the ^USorting and^u ^UGrouping^u button to display the Sorting And Grouping dialog box.
|
Choosing ^UView - Sorting and^u ^UGrouping^u has the same result.
|
You select the field you want to use - here it is ^UUnit Price^u.
|
In the Sort Order drop-down list, you click the option you want, for example ^UDescending^u.
|
After you close the dialog box, you can switch to ^UPrint Preview^u.
|
As you can see, Access has applied the new sort order.
|
The Report Wizard automatically generates default page numbering in the page footer section of a report.
|
Suppose you want to change the page footer generated by the wizard.
|
The easiest way to do this is to select the page number control and edit the expression in Design view.
|
For example, you type
^R="Page" & [Page]^r
|
In Print Preview, you can see that the new expression changes the page numbering style.
|
You can also add controls, such as labels and pictures, to reports.
|
Let's see how you create a label for a report header.
|
You click the ^ULabel^u button to create a label control.
|
Then you click where you want to place the label.
|
You type the text for the label.
|
And then you press ^UEnter^u.
|
You can move, size, or align selected controls.
|
Let's see how you size a group.
|
To select several controls, you hold down the ^UShift^u key as you click each control.
|
You choose ^UFormat - Size^u which allows you to resize all selected controls.
|
For example, you can make the selected controls as narrow as the narrowest control by selecting ^UTo Shortest^u.
|
Access resizes the selected controls.
|
Access allows you to change the appearance of an entire report or selected parts of it.
|
Suppose you want to change the font, font size, and line weight for all text and lines on the report at once.
|
You select the entire form by clicking the ^UForm Selector^u.
|
You click ^UAutoFormat^u.
|
Choosing ^UFormat - AutoFormat^u has the same result.
|
You select a new autoformat for the report, ^UBold^u for example.
|
You click ^UOK^u.
|
Access applies the new format.
|
To make more detailed changes to the appearance of your controls, you select the controls you want to format.
|
Then you can change the format using the formatting options on the Formatting toolbar.
|
Let's use one of the ^USpecial Effect^u buttons to give the selected controls a shadowed effect.
|
You click the ^USpecial Effect^u button, and then select the ^UShadowed^u option.
|
Access applies the new format.
@@
@@
A subreport is a report that's inserted in another report.
|
When you combine reports, one of them must serve as the main report.
|
The main report is either bound or unbound.
|
An unbound main report can store unrelated subreports that you want to combine.
|
If a main report is bound, it means that it is based on a table, query, or SQL statement.
|
In Access 97 you can nest subforms and subreports in a main report.
|
You can create an outer report or main report in the usual way using the Report Wizard, and then embed a subform or subreport in it.
|
A main report can contain up to two levels of subforms and subreports.
|
For example, a report can contain a subreport, and that subreport can contain a subform or a subreport.
|
Let's see how you create a subreport, and embed it in the group header of the main report.
|
You select the ^UStock Report^u.
|
You click the ^UDesign^u button to open the Stock report in Design view.
|
Then you click the ^USubform/Subreport^u button.
|
You click where you want to place the subreport in the group header.
|
You have the option to use a table, a query, or an existing form on which to base your subreport.
|
Here you click ^UTable/Query^u.
|
And you click ^UNext^u.
|
You select ^USales^u.
|
Then in the Available Fields list box, you click the fields you want to appear in your subreport.
|
Here you select ^UCustomer^u ^UID^u, ^UProduct ID^u, ^UUnits sold^u, and ^UUnit Price^u.
|
In most cases, a subreport is linked to a main report, so it shows records that are related to the current record on the main report.
|
To set up a link, you click the ^UChoose from a list^u radio button.
|
You select the appropriate link, in this case ^UShow^u ^USales for each record in^u ^UProducts using Product ID^u.
|
And then you click ^UNext^u.
|
You enter an appropriate name for your new subreport, for example ^RSales^r ^Rsubreport^r.
|
Then you click ^UFinish^u to close the dialog box.
|
Access embeds the subreport in the main report.
@@
Access makes it easy to print database objects.
|
For example, you can print
ò the datasheet of a table,
or a form
|
ò a selection of records
|
ò a grouped report
|
Unless your report or form is designed solely for online distribution, you'll usually want to print it.
|
The quickest way to print a report is by using the ^UPrint^u button.
|
The ^UPrint^u button method is suitable for reports, tables, and forms that are already formatted.
|
It is also an easy way to print the datasheet of a form or a table quickly.
|
When you click the ^UPrint^u button, Access prints the entire document using the default print settings.
|
Sometimes you may want to change printing defaults.
|
For example, you could set different default print margins to suit a particular document.
|
To do this, you click ^UTools - Options^u.
|
You click the ^UGeneral^u tab.
|
In the Print Margins area, you set the margins you want to use as defaults.
|
Changing default margins doesn't affect the margin settings for existing forms and reports.
|
You click ^UApply^u.
|
And then you click ^UOK^u to close the dialog box.
|
Since your report is grouped, you might want to set the Keep Together property.
|
Setting this property prevents page breaks in the middle of a group.
|
You select ^UDesign View^u in the View drop-down list.
|
You click the ^USorting and^u ^UGrouping^u button.
|
In the Keep Together field, you select ^UWhole Group^u.
|
Then you close the dialog box.
|
You could preview your document before printing it.
|
You simply click ^UPrint Preview^u in the View drop-down list.
|
You can use the navigation buttons at the bottom of the Print Preview window to move between pages.
|
Once you are satisfied with the layout of your report, you can print it.
|
To do this you click ^UFile - Print^u.
|
You enter the settings you want in the Print dialog box.
|
For example, in the Printer area, you specify a printer.
|
Similarly, in the Print Range area you specify whether you want to print all pages or a range of pages.
|
For example, if you only wanted to print five pages, you could enter the details in the Print Range area.