Creating and Using Reports

Total Page:16

File Type:pdf, Size:1020Kb

Creating and Using Reports

Fundamentals of Access 2003 Creating and Using Reports

Understanding reports...... 1 Creating reports using a wizard...... 1 Modifying reports...... 4 Report design vocabulary...... 4 Setting properties for the entire report...... 5 Specifying the data source for a report...... 5 Changing the title of a report...... 5 Getting to know the Toolbox...... 5 Creating new controls...... 6 Creating an unbound control...... 7 Binding controls to a record source...... 7 Working with controls...... 7 Understanding report sections...... 7 Creating a summary report with no individual records...... 8 Adding or deleting section headers and footers...... 8 Specifying what pages have headers and footers...... 8 Creating a page header that displays the first field value...... 9 Adding sections to group records...... 9 Adding page numbers...... 10 Adding date and time controls...... 10 Creating subtotals and totals...... 10 Counting the total number of records in a report...... 11 Creating a running sum...... 11 Avoiding space between fields...... 12 Controlling the size of fields...... 12 Preparing to print your report...... 12 The mystery of the blank pages...... 12 Changing the orientation of your paper...... 13 Changing margins...... 13 Modifying page breaks...... 13 Printing a report...... 14 Creating a “snapshot” version of a report...... 14 Understanding reports

Reports are used in Access to present information in a printed version. Behind the scenes, they are quite similar to forms in how they are created and modified. Reports can include information from queries or from multiple tables and allow you to group, summarize, and total your data. The differences between forms and reports include these features:  Grouping and sections: you can have up to four grouping levels and display subtotaling information for each of them  Page headers, footers, and numbers: Unlike forms, reports usually need information at the top and bottom of each page.  Margins, paper size, and paper orientation: Because reports are designed to be printed, you must remember to configure your report to fit on whatever paper you plan to use.

Creating reports using a wizard As with forms, your best bet when creating a report is to start with a wizard and then customize from there. In the Database window, click on the Reports button in the Objects list. Click on the “Create report by using wizard” link. The first step is to select the field(s) you want to use in your report from the appropriate table(s) and queries. Use the left- and right-facing arrows to select and deselect fields as necessary. Click on the Next button after selecting fields.

Depending on the type of fields you selected, you will be given the option here to group data, which can be very helpful in organizing a report logically. Select the appropriate field and click on the right-facing arrow so that it moves to the top of the screen. A Grouping Options button may then become available; click on it to specify the grouping intervals. In the screenshot

Fundamentals of Access 2003: Reports 1 shown here, I have chosen to group data by the field ClientLastName. Click on the Next button after selecting a grouping option. In the next screen, you can specify sorting options within the lowest-level grouping. Note that Access will automatically sort first by whatever you set as your grouping option in the prior step. If you did not choose to group in the prior step, you can sort by any of the fields selected for the report. Click on the dropdown arrow and choose the field name, and then specify whether the

sort should be Ascending or Descending. If your report includes numeric fields, the Summary Options button will be available. Click on this button to choose to create any of the following values for your data:  Sum  Average  Minimum  Maximum In the “Show” area on the right side of the screen, you can specify whether you want these operations calculated at the detail level (for each grouping level) and the report as a whole, or just for the report as a whole. You can also have Access calculate the percentage of the total

that each grouping represents by checking the “Calculate percent of total for sums” box. Click on the OK button once you have made all your summary choices; you will be returned to the Sorting screen, where you can click on the Next button. Choose the layout option for your report. Note that on this screen you can specify paper orientation as well. If your report includes a lot of data it is a good idea to select one of the “Align Left” format options and switch to Landscape orientation.

Fundamentals of Access 2003: Reports 2 Click on the Next button after making layout choices. Select the design style you would like to use for your report; you will be able to modify all of these choices later, so don’t spend a lot of time agonizing over your limited choices here.

Click on the Next button when done. Give the report a name, which will also be the title of the report initially. As with the style changes mentioned above, this name information will be easy to change later.

Click on the Finish button. The report appears on the screen; it may be exactly what you need, or, it may require a lot of work.

Note: if your report requires different data to get the information you need, it may be more time efficient to start over again, rather than trying to insert a lot of additional fields into your existing report.

Fundamentals of Access 2003: Reports 3 Modifying reports

When it comes to making changes to your reports, there are several categories of actions you can take:  Changing specific properties for the whole report  Changing properties of individual controls  Adding new controls  Deleting existing controls

Report design vocabulary Control: an object on the report that displays information. Generally speaking, a control is the report’s equivalent to a field in a table. If you have a control displayed, it will most likely have a label associated with it. That label identifies the name of the control (and draws from the field name or caption information you specified in table design view).

Toolbox

Field list

Properties sheet

Design grid Grid: In design view, the background of the window displays a grid of lines and dots to help you line objects up neatly. You’ll always know you’re in design view if you see the grid. Toolbox: this is a floating toolbar that displays a button that allows you to create each type of object you might need in your report. Field list: all the fields that you chose to include in your report when you ran the report creation wizard. Properties sheet: displays the properties of whatever object is currently selected. You can access the Properties sheet by clicking on the View menu and selecting Properties, or by right- clicking after selecting an object and then selecting Properties from the shortcut menu. There are multiple tabs on the Properties sheet, depending on the type of object selected. The All tab contains all the properties for that object or control.

Fundamentals of Access 2003: Reports 4 Setting properties for the entire report If necessary, you can set properties for the entire report. Select the entire report by clicking on the Report Selector button in the upper-left corner of the report, or by clicking on the dropdown arrow at the top of the Properties sheet and selecting Report.

Report Selector button

Specifying the data source for a report The record source property determines the table(s) or query(ies) from which a report draws its data. Generally speaking, it’s not a good idea to change the record source for a report, because if you’re using different data you should just create a different report. However, if you have created a query to filter the set of fields, you would want to change the record source. In the Properties sheet, select either the Data or All tab. Record Source is the first property. Click on the dropdown arrow and select a different source.

Changing the title of a report Modify the text that displays in the blue title bar by clicking into the Caption property (Format tab). The title bar is usually the same as the name of the report, but if you’re using a specific naming protocol, that report name may be confusing for users.

Getting to know the Toolbox Button Name What it does or creates Select Objects Allows you to select specific objects so that you can edit them. Control Wizards Runs the wizard associated with whatever type of control you want to create. Label Text that can be placed on the report

Text Box Text box control that can be bound to a specific field

Option Group Group of option buttons (radio buttons), check boxes, or toggle buttons Toggle On/off button

Option Button Radio button that is part of an option group

Check Box Box that does or doesn’t contain a check mark

Fundamentals of Access 2003: Reports 5 Button Name What it does or creates Combo Box Dropdown menu where you can choose from existing options or type in your own text List Box Dropdown menu where you can choose from existing options; no ability to type in your own text

Command Button Button that performs an action when clicked

Image Picture

Unbound Object Embedded object that is not stored in a table field Frame

Bound Object Frame Embedded object that IS stored in a table field

Page Break Break between pages of a report

Tab Control Tab for displaying different controls (like the tabs at the top of many windows)

Subform/subreport Adds a subform

Line Line for separating parts of a report

Rectangle Rectangle for visual effect

Creating new controls The most important thing to remember about creating new controls is that they must be bound, or connected, to an existing field in your table or query. Otherwise, Access will not know what data to display for that control Note: the exception to this rule is if you are performing some sort of calculation or writing an expression. The easiest way to create a new bound control is as follows: Click on the field you want to add in the Field List window, and then drag it onto the report. Access creates a control for you, usually a text box that comes with an associated label. If you switch to report view you can see what your report looks like with the new field included.

Creating an unbound control

Fundamentals of Access 2003: Reports 6 Because Access defaults to creating text boxes when using the above method, it is sometimes easier to create an unbound control and then specify the appropriate record source. In design view, click on the appropriate control type in the Toolbox. Click into the report window where you want the control to appear. Depending on the type of control you selected, a wizard may appear to help you configure the control. Notes on specifying the properties for different control types appear in the following sections.

Binding controls to a record source Before you do anything else with your control, be sure to specify the field to which it connects in your table or query. Click on the Properties sheet and select the Data or All tab. In the Control Source field, click on the dropdown arrow and select the correct field. Note: take this opportunity to make sure that the label name makes sense. It is usually good practice to have the field label be similar to the control source.

Working with controls You must select a control before doing anything with it. When you click on a control, small black boxes appear on the its corners and in the middle of each side. These boxes are called selection handles. When you select a control, you also select its label, if it has one. This is very handy for keeping labels and controls together, but it can be irritating if you want to move them separately. To select only the control and not its label: click the box in the upper-left corner of the control. The cursor turns into a little hand when you hover over the correct box. To select only the label and not the control: click the box in the upper-left corner of the control. The cursor turns into a little hand when you hover over the correct box. Common operations when working with controls:  Moving: Click on the control and drag to a new location.  Renaming: Click on the control to select it. Click into the Name property (Other tab) and enter a new name.  Resizing: Hover over a handle in the correct spot and then drag to resize. Note that radio buttons cannot be resized.  Deleting: Select the control and then hit the Delete key.  Copying: Select the control and then use the regular copy-paste commands: o Ctrl+C to copy o Ctrl+V to paste  Changing control type: Right-click on the control and select Change To from the shortcut menu

Understanding report sections Each report is broken into several different parts:  Report header and footer: appears at beginning and end of the report and contains summary information, such as report title and grand totals for data being calculated.  Page header and footer: appears at the top and bottom of each page and usually includes the report name, the date, and the page number.

Fundamentals of Access 2003: Reports 7  Section header and footer: appears at the top and bottom before and after the first and last record in a particular grouping level. If you have multiple grouping levels, there will be multiple section headers and footers. Subtotals for each grouping level often

appear here.  Detail: appears after the section header or after the report header if no grouping levels are established. The detail area displays individual values for each record used in the report and can include calculated fields. In design view, these parts are labeled at the top of the gray bar that spans each part, and the parts can be resized vertically be clicking and dragging at the top of the gray bar BELOW that section. Some sections may be repeated many times in a printed report. In the example shown above, the ClientLastName header prints once for each client who has a service record. The detail section prints once for each client, and it will contain a list of all the services used by that client. The ClientLastName footer prints once for each client who has a service record and contains summary information reporting the sum of costs for services, as well as the highest and lowest prices of services used by that client.

Creating a summary report with no individual records The Detail section cannot be deleted from any report, but you can leave it blank to create a summary report with subtotals and totals but no individual records. Delete all of the fields in the detail section and then drag the top of the lower edge (either the section footer or the page footer) up to meet the bottom of the Detail gray bar.

Adding or deleting section headers and footers Most of these sections will be added by default when you use the report wizard. However, if for some reason they are not there, click on the View menu and select Page Header/Footer or Report Header/Footer. To delete a header or footer, remove any controls in that section, and then drag the bottom border of the section up to the top border.

Specifying what pages have headers and footers Switch into design view.

Fundamentals of Access 2003: Reports 8 Click on the blue title bar for the report so that the report’s properties will be displayed in the properties sheet. Click on the Format menu and then select either Page Header or Page Footer. A dropdown list appears with the following choices:  All Pages  Not with rpt hdr  Not with rpt ftr  Not with rpt hdr/ftr

Creating a page header that displays the first field value If your report is extremely long, it may be helpful to create a field in the page header that displays the first field value on that page—for example, the last name of the first client referenced on that page—so that it is easier for users flipping through the report to find their way around. Switch into design view. Select the appropriate control from the section header, such as the client last name. Click on the Edit menu and select Copy. Click on the gray bar for the Page Header section to select it. Click on the Edit menu and select Paste. The client last name control, along with its label, should now be copied into the page header. You can delete the label, if preferred. Click into report view to see how the report looks. If you don’t like having the client last name on the top of each page, simply delete the control from the page header.

Adding sections to group records Although you get grouping options when you run the report wizard, you may realize later on that you need to create additional grouping levels, or you may decide to group by another field. Switch into design view. Click on the Sorting and Grouping button on the toolbar, or click on Sorting and the View menu and select Sorting and Grouping. Grouping button In the Sorting and Grouping window, any fields that are already being used to group or sort your report are displayed. To add a new grouping level or specify a sort, click into the first blank row and select the appropriate field from the list of available fields.

To make this field into another grouping option, click into the Group Header box in the Properties area and change the setting to Yes. To add a footer for this new grouping level, click into the Group Footer box and change the setting to Yes. To add another layer of sorting, add the additional field as explained above. In the Sort Order column, specify Ascending or Descending for the type of sort you want it to perform.

Fundamentals of Access 2003: Reports 9 Close the Sorting and Grouping window by clicking on the red X in the upper-right corner. Note: while you can specify sorting in the underlying table or query, specifying a sort in the report itself is the best way to ensure that your data always sorts the way it should for this report.

Adding page numbers Click on the Insert menu and select Page Numbers. In the Page Numbers window, choose the

format, position, and alignment. Note that you can also choose not to display numbers on the first page of the report by checking the box at the bottom of the window. Click on OK.

Adding date and time controls Switch into design view. Click on the Text Box button in the Toolbox and then click and drag to draw a text box in the appropriate section of the report. Access will create an accompanying label, which you don’t need to keep. In the Properties sheet for the text box, select the Data tab, click into the Control Source box, and type the following expression: =Now() This expression will display the date and time. To display only the date, click on the Format tab, click into the Format property, and select a date format from the dropdown list.

Creating subtotals and totals When you create a report using the report wizard, you get the chance to set up subtotals and totals on any numeric fields. The control for a subtotal looks something like this (depending, of course, on the field names):

Design view

Report view

Fundamentals of Access 2003: Reports 10 To create your own subtotal or total controls: Switch into design view. Click into the Toolbox and select the Text Box tool. Draw a textbox where you want the new total or subtotal information to appear. Note: Subtotals must be created in the header or footer for that section. If you put a subtotal in the page header or footer, you will get an error message. To create a total, place the control in the report header or footer. Open the properties sheet for your new control and enter the following expression in the control source box. =Sum([insert your fieldname here])

Counting the total number of records in a report Record count expressions for a report must be created in the report header or footer. Switch into design view. Click into the Toolbox and select the Text Box tool. Draw a textbox in the report header or footer where you want the total records count to appear. Open the properties sheet for your new control and enter the following expression in the control source box. =Count(*)

Creating a running sum In a report, Access can give you totals for individual records as well as running sum totals. To avoid confusion, it is probably a good idea to create two text box controls for the same numeric field: one that shows the value for the current set of records, and one to show the running sum value (see example below):

Switch into design view. Click into the Toolbox and select the Text Box tool. Draw a textbox in the section header or footer where you want the numeric totals to appear. Open the properties sheet for your new control and point it to the correct numeric field in your underlying table or query. Note: if the numeric field already appears in the report, you do not need to perform this step. Once the numeric field has been created, copy and paste it into the same area so that you have a duplicate control. On the second version of the numeric field control, open the properties sheet and click on the Data tab. In the Running Sum box, click on the dropdown arrow and change the value to Yes or to Over All if it is included in the section header or footer.

Fundamentals of Access 2003: Reports 11 Avoiding space between fields To save space in a report containing many fields of information, it may be useful to concatenate some fields, so that their field contents are glued together with only a single space between the contents of the field. Good candidates for this treatment would be names and address information. To concatenate field names, you will create a new text box control and write an expression for it. Note: this operation can also be done in a query that is used as the basis for a report. Switch into design view. Click into the Toolbox and select the Text Box tool. Draw a textbox in the detail section where you want the information to appear. Open the properties sheet for your new control and enter an expression in the control source box. Two samples are shown below: = [FirstName] & “ “ & [LastName]

= [City] & “, “ & [State] & “ “ & [Zip] When concatenating text, remember that you must add in the necessary spaces between fields by enclosing a space between sets of double quotation marks.

Controlling the size of fields Text and memo type fields can cause formatting headaches, because the amount of text they contain may vary widely. Rather than trying to accommodate all the possible sizes, use the properties options for that control to allow for larger or smaller field sizes. Switch into design view. Select the control and then open its properties sheet. Click on the Format tab and then click into the Can Grow box. Select Yes from the dropdown list. Preparing to print your report

Printing reports in Access can sometimes be as frustrating as printing in Excel. In an effort to get all your fields on the page, you may inadvertently create a report that is too wide for your paper and end up printing extra, unnecessary pages. Always be sure to look carefully at your report in Print Preview mode before printing.

The mystery of the blank pages The most-common complaint about printing reports in Access is that it creates blank pages between each printed page. Most often, these blank pages exist because Access thinks you’ve made the width of your report too big to fit on a regular 8.5x11 sheet of paper, so Access splits the reports into two sections that can then be taped together. The default widths for reports should be:  Portrait orientation: 7.5 inches wide  Landscape orientation: 9 inches wide To check with width of your report: Switch into design view. Look at the horizontal ruler running across the top of the report’s design grid and see where the right-hand border falls. If necessary, click and drag on the right-hand border to decrease its width.

Fundamentals of Access 2003: Reports 12 Note: if you are unable to decrease the width, there is most likely a line or some other design element that extends too far to the right. All elements within the report must be sized down so that they fit into the desired width before you can decrease the width of the report as a whole.

Changing the orientation of your paper Click on the File menu and select Page Setup. Click on the Page tab.

In the Orientation are, choose the correct orientation for your report. Click on the OK button to close the Page Setup window.

Changing margins Click on the File menu and select Page Setup. The Margins tab should open by default. Modify the margins as necessary. Click on the OK button to close the Page Setup window. Note: if you find that all of your reports need to have the margins modified, change the default margin settings: Click on the Tools menu and select Options. Click on the General tab and modify the margin measurements there. Click on the OK button.

Modifying page breaks There are several different ways to add page breaks to your reports. To print one page per record: Switch into design view. Click into the Detail section and open the Properties sheet. Click on the Format tab. In the Force New Page box, click on the dropdown arrow and select either “Before Section” or “After Section.” To force a page break after each group of records: Switch into design view. Click into the Group Footer section and open the Properties sheet. Click on the Format tab. In the Force New Page box, click on the dropdown arrow and select “After Section.” To force a break within a section: Switch into design view. Click on the Toolbox and select the Page Break button. Click into the detail section of the report where you want the page break to occur.

Fundamentals of Access 2003: Reports 13 Printing a report When you have configured your page and margin options correctly and are ready to print, use one of the following options:  Click on the Print button  Click on the File menu and select Print  Use the keyboard shortcut: Ctrl + P

Creating a “snapshot” version of a report Access can save your report as a snapshot file, which allows you to email it to other users who can open the file without having access to the rest of your database (or even having the Access application available to them). Select the name of your report in the Database window. Click on the File menu and choose Export. If necessary, navigate to a different location where you intend to store the file. Click into the Save as Type box and select Snapshot Format. Enter a name for your file. Click on the Export button and the file will be created in the location you specified.

Fundamentals of Access 2003: Reports 14

Recommended publications