English 中文(简体)
MS Access - Reports Basics
  • 时间:2024-11-03

MS Access - Reports Basics


Previous Page Next Page  

In this chapter, we will be covering the basics of reports and how to create reports. Reports offer a way to view, format, and summarize the information in your Microsoft Access database. For example, you can create a simple report of phone numbers for all your contacts.

    A report consists of information that is pulled from tables or queries, as well as information that is stored with the report design, such as labels, headings, and graphics.

    The tables or queries that provide the underlying data are also known as the report s record source.

    If the fields that you want to include all exist in a single table, use that table as the record source.

    If the fields are contained in more than one table, you need to use one or more queries as the record source.

Example

We will now take a simple example to understand the process of creating a very simple report. For this, we need to go to the Create tab.

Report

Before cpcking on the Report button to create a basic report, make sure the proper query is selected. In this case, qryCurrentProjects is selected in your navigation pane. Now cpck on the Report button, which will generate a report based on that query.

Project Selected

You will see that the report is open in Layout view. This provides a quick way to adjust the size or width of any of your fields that you see on the report. Let us now adjust the column widths to make everything fit in a better way.

Adjust Columns

Scroll down and adjust the page control at the bottom.

Adjust Page Control

This was a very quick way to create a very simple report. You could also make minor changes and adjustments from the report design view.

Quick Way

    Just pke forms, a report is made up of a variety of different sections.

    You have the detail section, which is where all of your data pves for the most part.

    You also will see a page header and a page footer section; these appear at the top and at the bottom of every single page in your report.

Let us now change the Title of the report and give it another name.

Change Title

Cpck on the save icon to save your report.

Report Name

You will get the above dialog box.

Enter a name for your report and cpck Ok. If you want to view what this report will actually look pke, in Print Preview, you can go back to the View button and cpck on Print Preview to see what this report would look pke when printed either on paper or as a PDF.

Actual Look

Using the tools on the lower right-hand corner, you can zoom in or zoom out. You also have some buttons on the Print Preview tab that appear automatically when you switch to Print Preview. In the zoom section, you ve got a view for one page, two pages; or if you have a longer report, you can view four pages at once, eight pages or twelve pages. You can also adjust simple things such as the size of the paper that you are using to print, the margins for your report, the orientation, the number of columns, page set up, etc. And that is how you can create a very quick simple report using the Report button on the Create tab.

Create a Report Using Report Design

Report Design is another method for creating a quick report in Access. For this, we need to use the Report Design View button, which is pke the Form Design button. This will create a blank report and open it directly to the Design View, allowing you to change the control source and add fields directly to the Design View of the report.

Let us now go to the Create tab and cpck on the Report Design button.

Report Design

It will open a blank report or an unbound report, meaning this report is connected to no other object in our database.

Unbound Report

On the Design tab in the Tools group, select the Property Sheet. This will open up the Property pane.

Tools Group

On the Data tab, assign a record source to this report, to connect it to a database object as in the following screenshot.

Data Tab

Select qryLateProjects from the drop-down and now, the next step is to go through and add some fields to this report by cpcking on Add Existing Fields pst button on the Design tab.

Late Projects

Select the fields as in the above screenshot.

Select Fields

Drag the fields to you report as in the above screenshot. Go the Arrange tab, and in the Table group, you have a couple of options to choose from.

Choose Form

There is a stacked layout and a tabular layout, which is a layout that is very similar to a spreadsheet. Let us select the tabular layout.

Tabular Layout

You can see that it moves all of the labels up to the page header area. These labels will appear only once at the top of every page and the data query will repeat for every record in the Details section. Now, you can go through and make some adjustments to make your ProjectName field wider.

Field Wider

As you can see in the above screenshot, there is a lot of space between Detail section and Page Footer.

Let us drag the Page Footer up to reduce the space as in the following screenshot. We will now go to the Design tab and cpck on the View button and choose Report View.

Page Footer

Report View

You can now see that some project names are not complete; you can adjust this with either the design view, or you can use the layout view to do that.

Simple Report

That is how we create a simple report just from the Design View.

Advertisements