Ms Access 简明教程
MS Access - Reports Basics
在本章中,我们将介绍报表的原理以及如何创建报表。报表提供一种查看、格式化和整理 Microsoft Access 数据库中的信息的方式。例如,你可以为所有联系人创建电话号码的简单报表。
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.
在单击“报表”按钮创建基本报表之前,请确保选择正确的查询。在这种情况下,你的导航窗格中已选择“ qryCurrentProjects ”。现在单击“报表”按钮,该按钮会根据该查询生成一份报表。
Before clicking 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 click on the Report button, which will generate a report based on that query.
你将看到报表在版式视图中打开。这提供了一种快速方式来调整你在报表中看到的所有字段的大小或宽度。现在我们调整列宽,以便以更好的方式使所有内容都适合放置。
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.
向下滚动并调整底部的页面控件。
Scroll down and adjust the page control at the bottom.
这是创建非常简单的报表的一种非常快的方法。你还可以从报表设计视图进行轻微的更改和调整。
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.
-
Just like forms, a report is made up of a variety of different sections.
-
You have the detail section, which is where all of your data lives 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.
单击保存图标保存报表。
Click on the save icon to save your report.
您将看到上面的对话框。
You will get the above dialog box.
为报表输入名称并单击“确定”。如果您想查看此报表实际的样子,在打印预览中,您可以返回到“视图”按钮并单击“打印预览”查看此报表在纸张或 PDF 上打印时的样子。
Enter a name for your report and click Ok. If you want to view what this report will actually look like, in Print Preview, you can go back to the View button and click on Print Preview to see what this report would look like when printed either on paper or as a PDF.
使用右下角的工具,您可以放大或缩小。当您切换到“打印预览”时,还可以在“打印预览”选项卡上看到一些按钮,这些按钮会自动显示。在缩放部分,您可以查看一页、两页;或者如果您有较长的报表,您可以一次查看四页、八页或十二页。您还可以调整一些简单内容,例如打印要使用的纸张大小、报表页边距、方向、列数、页面设置等。这就是使用“创建”选项卡上的“报表”按钮创建非常快速简单的报表的方式。
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
报表设计是使用 Access 创建快速报表的另一种方法。为此,我们需要使用报表设计视图按钮,它类似于窗体设计按钮。这将创建一个空白报表并直接将其打开到设计视图,这使您可以更改控件源并直接将字段添加到报表的设计视图。
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 like 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 click on the Report Design button.
它将打开一个空白报表或一个未绑定的报表,这意味着此报表未连接到我们的数据库中的任何其他对象。
It will open a blank report or an unbound report, meaning this report is connected to no other object in our database.
在“工具”组中的“设计”选项卡上,选择“属性表”。这将打开属性窗格。
On the Design tab in the Tools group, select the Property Sheet. This will open up the Property pane.
在“数据”选项卡上,为该报表分配一个记录源,以将其连接到数据库对象,如下面的屏幕截图所示。
On the Data tab, assign a record source to this report, to connect it to a database object as in the following screenshot.
从下拉菜单中选择 qryLateProjects ,现在,下一步是单击“设计”选项卡上的“添加现有字段列表”按钮来添加一些字段到此报表。
Select qryLateProjects from the drop-down and now, the next step is to go through and add some fields to this report by clicking on Add Existing Fields list button on the Design tab.
选择字段,如上面的屏幕截图所示。
Select the fields as in the above screenshot.
将字段拖动到报表中,如上面的屏幕截图所示。转至“排列”选项卡,然后在“表”组中,您可以从几个选项中进行选择。
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.
有一个堆叠布局和一个表格布局,它们类似于电子表格。让我们选择表格布局。
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.
您会看到它会将所有标签移到页眉区域。这些标签只会显示在每一页的顶部一次,而数据查询会针对详细信息部分中的每条记录重复。现在,您可以进行一些调整,使您的 ProjectName 字段更宽。
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.
正如您在上面的屏幕截图中看到的那样,详细信息部分和页脚之间有很大的空间。
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 click on the View button and choose 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.
这就是我们只使用“设计视图”就创建简单报表的步骤。
That is how we create a simple report just from the Design View.