100% found this document useful (1 vote)
72 views20 pages

Chapter - 8 Reports and Macros: Report

The document discusses reports and macros in Microsoft Access. It provides instructions on: 1) How to create a report using the Report Wizard which guides the user through selecting fields, grouping, sorting, and formatting options. 2) How to modify an existing report by making changes in Design View such as editing field names. 3) How to add grouping, sorting, or totals to a report directly from the field or using the Group, Sort, and Total pane. 4) What macros are and how they can automate tasks and add functionality by linking database objects. 5) A step-by-step example of creating a simple macro to open a form when a command button is clicked

Uploaded by

SAKURA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
72 views20 pages

Chapter - 8 Reports and Macros: Report

The document discusses reports and macros in Microsoft Access. It provides instructions on: 1) How to create a report using the Report Wizard which guides the user through selecting fields, grouping, sorting, and formatting options. 2) How to modify an existing report by making changes in Design View such as editing field names. 3) How to add grouping, sorting, or totals to a report directly from the field or using the Group, Sort, and Total pane. 4) What macros are and how they can automate tasks and add functionality by linking database objects. 5) A step-by-step example of creating a simple macro to open a form when a command button is clicked

Uploaded by

SAKURA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Chapter – 8

Reports and Macros

 Report :

 A report is an object in MS Access that is designed for formatting, calculating and


printing selected data in an organized way.
 It contains information from tables and also information that are there in the report
design.
 Reports are helpful as they allow you to present all information of your database in an
easy-to-read format.

 Create a Report with the Report Wizard in Microsoft Access :


Similar to the Form Wizard, the Report Wizard walks you through a series of decisions in order

to build a report. To create a report using the Report Wizard, follow the steps below.

This feature works the same in all modern versions of Microsoft Access: 2010, 2013, and 2016.

1. On the Create tab in the Reports group, click Report Wizard. The wizard starts.


2. From the Tables/Queries drop-down list, select the table (or query) to base the report on.
The fields for the selected table load in the Available Fields list box.
3. Move the fields to include on the report from the Available Fields list box to
the Selected Fields list box. To do so, double-click a field name to move it or highlight
the field name and click >. To move all fields at once, click >>.
4. Click Next >.

5. To group records on the report by a particular field, highlight the field in the list box and
click >.

6. Add more grouping levels if desired. You can use the arrows to change the order of the
grouping levels if needed.
7. When you finish defining how you want records grouped, click Next >.

8. In the first drop-down list, select the field to sort records by. By default, records will be
sorted in ascending order by the field you select. If you want to sort in descending order,
click the Ascending button to change its label to "Descending".
9. You can specify up to four levels of sorting. When you finish specifying sorting options,
click Next >.

10. In the Layout field, select the format of the report. Your options are "Stepped", "Block",
and "Outline". (Try the options to see a preview of the report layouts.)
11. In the Orientation field, select whether to lay out the report in portrait or landscape
mode.
12. If you want all fields to fit on a single page, ensure the Adjust the field width so all
fields fit on a page check box is marked.
13. Click Next >.

14. Enter a title for the report.


15. Select an option for the view you want to open the report in. Your options are:
o Preview the report (opens in Print Preview mode).
o Modify the report's design (opens in Design view).
16. Click Finish. The report loads in the view you selected.
Once the wizard has done its job, future changes to the Sorting and Grouping are made in

the Group, Sort, and Total area: Design > Group & Sort. You may change the order

of, remove, or edit any existing items. You may also add a group and a sort as well.

Let take an example of 'Contact' DB default report – 'Phone Book.' Using Design View :

Step 1) Click on 'Phone Book' under 'Report' section. The system will open the inbuilt 'Phone
Book' report.It will display Contact Name, Home, Business and Mobile name displayed
for each record present.
Step 2) Now suppose that we want to edit the report Heading from 'Home' to 'Home Number.'
Right click and click on 'Design View.'
The system will open the Report in Design view.

Step 3) Edit the name you want to update and Press 'Ctrl+S'.

Step 4) Double click 'Phone book' under reports


Result: Label is updated from 'Home' to 'Home Phone.'

 Add grouping, sorting, or totals :


The fastest way to add grouping, sorting, or totals to a desktop database report is to right-click
the field to which you want to apply the group, sort, or total, and then click the desired command
on the shortcut menu.
You can also add grouping, sorting, or totals by using the Group, Sort, and Total pane while the
report is open in Layout view or Design view:
If the Group, Sort, and Total pane is not already open, on the Design tab, in the Grouping and
Totals group, click Group & Sort.
Click Add a group or Add a sort, and then select the field on which you want to group or sort.
Click More on a grouping or sorting line to set more options and to add totals.
For more detailed information about grouping, sorting, and totals, see the article Create a
grouped or summary report.

 Macros :

 Macro in MS Access is a time-saving feature that allows you to add functionality or


automate simple tasks.
 Steps that are of frequently used can be automated using a macro
 It can add a quick and easy approach to link all other objects together to create a simple
database application.

 Creating a Macro :

Let us start be creating a very simple Macro that opens a form when a command button is
clicked. For this, we need to open your database and frmEmployeeData form in which we
have created two tabs.

In this form, we can add a button allowing users to open up all of the job information.
Let us now go to the Design View of this form and add button form the Controls menu.
When you release your mouse, you will see the Command Button Wizard dialog box.

There is a couple of ways to build that Macro action, but the simplest way is to simply use
the Command Button Wizard.

For common actions like opening a form, select Form Operations from the Categories list
and then select Open Form from the Actions list and click Next as in the above screenshot.
You need to specify which form you would like to open with the command button. For now,
let us select frmJobs and click Next.

In this screen we have two options, we can open the form and display a very specific
record, or we can open the form and show all the records. Let us select the second option
and click Next as in the above screenshot.
We could have the command button itself display a picture or you can select the Display
Text. Here, we want the text View Jobs to display and now click Next.

You can now provide a meaningful name to your command button as in the above
screenshot. This can be used in other codes or other Macros. Let us call
this cmdViewJobs and click Finish.
Now go to the Form View.
You will now see a View Jobs button on your form. Let us click on it.
Now you have a form open, but you will not be viewing any information. Let us go back to
the frmEmployeeData form Design view. Make sure that the command button is selected
and click on the Event tab on the Property Sheet.

Upon clicking, you will see an embedded Macro created by the Wizard. If you now want to
modify this Macro, click on the … button to open up the Macro generated by the Wizard.
This is the Macro Designer and on the right you will see the Action Catalog. This is where
all of your actions will live in folders. You have the Data Entry options, Data Import/Export
and so on, and on the left in the main area you have another Macro. It only contains one
action, and clicking on that one action you can view other properties for that specific action.
You will see the form name and you can hit that drop-down arrow to view the forms
available in your database. You can change how that form is viewed, you can have it open to
Form view, Design view, Print Preview at your choice. You can apply a filter name or a
Where condition. Here we want to change the Data Mode because frmJobs is set to the Add
Mode which only allows the addition of new records. We can override this here in this
Macro by changing it to the Edit Mode.
Now save your Macro, and then close the Macro Designer and go back to the Form View.

Let us click on View Jobs again.


You can now see that it opens your frmJobs form and allows you to scroll through all of the
available jobs in our database.

You might also like