CREATING A REPORT IN ACCESS

 

Access contains wizards that make creating reports very easy.  However, sometimes wizards do not create the report the way you want it, or you may need to make modifications.  With this in mind, it's helpful to know a little bit about creating a report from scratch.  

Throughout this handout, you will see the phrase "should look something like this" followed by an example.  Creating reports can be very tedious.  The examples are shown to keep you on the right track, but your report may not look exactly like the example. The position of your fields may be slightly different, or your spacing may be a little different.  All of these things can be corrected with time and patience, so do not worry if you have a minor difference.  If, however, you have a major difference, please review the steps you just completed.

The report in this handout will be created on the First Period query in the New School 3 database.  Click here to download the database. A relationship has been established based on the SSN field in the Student Info table and the SSN field in the Student Schedule table. The First Period query contains the SSN, FirstName, and LastName fields from the Student Info table, and the FirstPeriod field from the Student Schedule table.  No critieria were used in the query.

If you need to review how to create queries or relationships, please refer to the Beginning or Intermediate Access handouts at  http://learningcenter.clayton.edu/fidl/online.htm

1. Click on Reports, New, Design View.  Click on the list arrow and choose the First Period query. Click on OK.
 

2. The report will open in Design view. You will also need the Toolbox, so if it doesn't appear, click on the Toolbox icon (wrench and hammer).
3. At this point, the report has 3 sections: Page Header, Detail, and Page Footer.  Other sections that can be added include Report Header, Report Footer, Grouping Header and Grouping Footer.  The characteristics of each section vary:
  Report Header Appears at the top of the first page of the report. The title of the report usually goes in the report header.
  Page Header Appears at the top of every page of the report. Column headings usually go in the page header.
  Grouping Header If grouping has been selected, the grouping header may appear at the top of each new group. Grouping headers are optional.
  Detail Section This section contains the field values from the table or query that the report is based on.
  Grouping Footer If grouping has been selected, the grouping footer may appear at the bottom of each new group. Grouping footers are optional.  Subtotals might be placed in the grouping footer.
  Page Footer Appear at the bottom of every page of the report. Page numbers usually go in the page footer section.
  Report Footer Appear at the bottom of the last page of the report. A grand total should be placed in the report footer.
  Note the sections at the far right side of this screen capture of a report. Grouping footers and page footers were not used.

4. Click on View in the menu bar, then Report Header/Footer to add these sections.
5. We will not use the page footer, so move the mouse to the top of the report footer bar; the mouse will change to a double-headed arrow.  Click and drag the report footer bar up until it meets the bottom of the page footer bar.  This closes the page footer bar so that it will not take up unnecessary space. Your screen should look like this:

6. Next, we need to add the Sorting/Grouping Header.  Click on the Sorting/Grouping icon on the toolbar. We want to group on the First Period class, so click on the list arrow at the right side of the field expression box and select First Period. Click in the group Header area, click on the list arrow, and select Yes.  This adds the group header.

7. Close the Sorting and Grouping window.  You should now have the following sections in your report: report header, page header, first period header (this is the grouping header - it takes its name from the grouping field we selected), detail, page footer (which we have closed up), and report footer.
8. Now we can begin adding the fields into the report.  Click on the Field List icon, and the list of available fields from our First Period query should appear.  Click on the first field, SSN, and drag it down into the detail section. Repeat for FirstName, LastName and FirstPeriod.  It really doesn't matter where you put them, but try to line them up something like this:

9. Close the Field List window.  We have all of the fields we need. 
10. The items in the detail section are called controls, and in this case, they are bound controls.   This means that they are directly linked to the underlying table or query.  Bound controls consist of two parts, the label box, which in our example is on the left, and the text box which is on the right.  You can change or delete the label box and the report will still run.  However, you can not change the contents of the text box.  If you do this, you have changed the name of the field that the report is searching for in the underlying table or query, and the report will not work.
11. Each set of controls can be moved separately or together.  Click on the SSN text box control (the one on  the right). A set of handles should appear on that control, and a single handle should appear on its associated label control. Notice that the first item on the left of  the formatting toolbar says SSN. This is the object list.  Click on the list arrow on the object list, and you'll see all the other objects and their labels.  Click on some of the other objects and watch the handles move to select those objects.  You can use this object list as a visual clue to determine if you have a text box or a label selected.  Text boxes will show the field name in the object list; labels will show label x (where x is some number).  Hopefully, this will help to prevent you from making changes to contents of the text box controls. 

Click back on the SSN text box control, then move your mouse to the top of the text box control. Your mouse pointer should change to a hand. If you click and drag. the hand allows both the text box and the label to move together, keeping their relationship to each other.  Now move the mouse to the larger handle located at the top left of either the text box or the label.  Your mouse should change to a pointing finger. Clicking and dragging with the finger pointer will move only that control.   

 

12. All of the labels in our report are at the top of the page in the page header, so we will need to move them there.  You can not click and drag across the boundaries of a section, so we will cut and paste instead.  You can select more than one control at a time by clicking on the first control, then holding the Shift key down and clicking on the other controls. 

Click on the SSN label box, hold Shift down, and click on the other label boxes to select them.  When you finish, there should be handles on all of the label boxes. 

Click on the cut icon.

Click anywhere in the Page Header section, then click on paste.  The labels should move to the Page Header section. Your screen should look something like this:

Click anywhere in the Page Header section to deselect the labels.

13. By clicking and dragging, begin aligning the labels in the Page Header section with the text boxes in the Detail section.  You can check your progress by changing to Print Preview and back to Design View.  Use the first icon on the left to change views.  

This is a tedious process - sometimes you have to go back and forth many times to get things aligned just right.  Using the Grid dots is helpful, but the Align tool can help speed up the process.  

Select the SSN label in the Page Header, hold Shift down, then select the SSN text box in the Detail section. 

Click on Format, Align, and choose which side to align on.  This will align both controls at whatever side you choose.

Try to make your report look like this:

You must leave enough space between the controls, especially in the detail section, for the student's entire SSN, first name and last name to show.  This may mean that you need to increase the size of the controls, which you can do by clicking and dragging on the handle on the right side of a control. Change to the Print Preview and scroll through the pages of the report. You can change from page to page by clicking on the navigation buttons in the bottom left corner of Print Preview.  

Notice that neither of the FirstPeriod controls is aligned.  These will be moved into the FirstPeriod Header in the next step.

14. Select the FirstPeriod label, which is now in the Page Header section. Cut and paste it into the FirstPeriod Header section.  Do the same for the FirstPeriod text box that is in the Detail section.  Position them at the far left  of the grid, using the Align command to adjust them vertically. Chance are they will paste right on top of each other, so try to use the finger pointer to get them separated. Now the Report Design looks something like this:

If you change to the Print Preview, alignment is probably close, but there is a great deal of blank space in the report. In the next step, we'll close up the sections to get rid of the white space in the report.

15. Move your mouse to the top of the Page Footer bar; it should change to a double-headed arrow.  Drag the Page Footer bar up until it almost touches the bottom of the text boxes in the Detail section.  Repeat for at the top of the FirstPeriod Header bar - drag it up until it almost touches the bottom of the label boxes in the Page Header section.  Your design should look something like this

When you change to Print Preview, your report should have shrunk down to one page.  However, it is hard to distinguish where you change from one class to another, so in the next step we'll add a line and some formatting to make the report easier to read.

16. If your toolbox is not visible on your screen, click on the toolbox icon. The toolbox should appear as a floating toolbar. 

The toolbox contains icons for many things, including some unbound controls such as lines and labels. Unbound controls are in no way connected to the underlying table or query.  You can move them or change them to suit you without worrying.

Click on the line icon on the toolbar.  Drag your mouse just under the controls in the FirstPeriod Header to draw the line.  If you hold Shift down while you drag, you will be assured of a straight line. 

Preview the report.  The line helps, but it would be better if it were thicker, if the controls were bolded and if there was a space between First and Period. Go back to the Design View to make these changes.

17. Point to the line and click to select it.  If this proves too difficult, remember you can use the Object list at the left side of the formatting toolbar.  Click on the list arrow and select the line (it should be the only one, so it doesn't matter what number it is). Once the line is selected, the handles should appear on the line.

Each control has properties.  Click on the Properties icon on the Report Design toolbar.  Since the line was selected, the Line Properties window should appear.

Click on the Border Width box, then click on the list arrow that appears to the right, and select 2 pt.  This will make the line fatter and easier to see.  Preview the report.

18. Change back to the Design View.  Select both the FirstPeriod label and text box (remember to hold shift down), then click on the Bold icon. Preview the report to see the difference.

Change back to the Design View.  If both the label and text box are still selected, click somewhere to deselect.  Then select only the label box (be sure about this!) We need to put a space between First and Period.  There are two ways to do this.

Either select the label box, click on Properties, then change the caption to read First Period, or

Click once on the label box, then click again (2 single clicks, not a double-click). This should put you into the Edit mode for the label.  Put a space between First and Period.  

Either method will work.  What's important to remember, though, is that you are doing this on the label, NOT the text box.  If you ever should change a text box beyond repair, delete the text box and its corresponding label, click on the Field List icon, and drag the field back into the Report.  You'll then have to move and edit it back to its proper location and formatting.  

A good clue that you have changed a text box is this: when you preview the Report, you get a Parameter message.  This is usually what happens when Access can't find a bound control that's in the report, but not in the underlying table or query. 

At this point, the report should look something like this in Print Preview:

If the lack of a space between Chem and 101 or Eng and 101 bothers you, you would need to go back to the Student Schedule table and change all the records, adding spaces appropriately.  

19.  The report would look better with a title.  We'll put the title in the Report Header, so that it will appear only once, at the beginning of the report.

Click on the Label tool on the Toolbox.

Drag and draw a box in the Report Header section.  The size of the box really doesn't matter - we can adjust it later.

As soon as you left your finger off the mouse, you'll go right into editing the contents of the label.  Key in First Period Student Roster, then click someplace outside of the box to get out of the editing mode. Preview the report.  The title needs to be bigger and bolder. Go back to the Design View.

Select the label box; handles should appear around it. Select 18 pts and Bold on the Formatting toolbar.  However, as soon as you do this, the text becomes too big for the box. 

Click on Format, Size, To fit.  This should adjust the box size, although you may have to drag the handle at the far right to increase the length of the box.  

While the box is selected, you could also change the font face, color, fill or back color and alignment by using other icons on the formatting toolbar. 

Move the label so that it aligns at the left side of the report. Check it with Print Preview.

20. At this point, your report should look something like this:

The report fits all on one page and it is readable.  Note how the students in each class are grouped by the name of the class they are taking.  This is the Grouping Header (FirstPeriod Header) at work.

21. Our example report also had a counter in the Report Footer.  This is a calculated control.  Calculated controls display values calculated from one or more fields in the underlying table or query.  To create a calculated control, use the text box icon on the Toolbox, then key in the formula.

The section that a calculated control is placed in plays an important role.  For instance, if you wanted to find the sum of all invoices for companies in a particular state, where the field is called Invoice, the formula =sum([Invoice]) would be placed in a text box in the Grouping header for State. Think of this as a subtotal.  The exact same formula placed in the Report Footer (the last thing in the Report) would produce a grand total.  

Formulas used for calculated controls are very similar to those used in Excel.

Our example has a calculated control in the Report Footer that counts the number of students in our roster. To create this:

Click on the text box icon on the Toolbox, then click anywhere in the Report Footer section.  The text box and its accompanying label will appear. The text box has "Unbound" in it.

Click on Unbound, then key in this formula =count([LastName]).  This will count the number of last names in the detail section. Note the use of both the parentheses and the brackets and their position.  Also the name of the field must be spelled identically to the way it is in the underlying table or query.

Select the text box (the one containing the formula), then click on the left align icon on the Formatting toolbar.  Numbers align to the right by default.  By changing the alignment to left, there will not be as big of a gap between the label and the number.

Click in the label box, delete the contents, then key in Total Students.

Align the boxes at the left side of the report, then switch to Print Preview.  The total should be 10 and your finished report should look something like this:

Close the report. Save it as First Period Student Roster.

22. Things that may cause problems in reports:

If you get a message that some of the area of the report is outside the printable area, take a look at the width of the grid.  It can be adjusted by dragging the right side of the grid.  You can also change the paper to landscape by clicking on File, Page Setup.

Watch out for typos in field names.  Again, a big clue is the Parameter query message. If that happens, go back and start looking at field names in the report.

If you try to open a report and you get a message that tells you the table or query that the report is based on no longer exists or the name may have changed, stop and think.  Did you change the name of a table or query lately, or delete a table or query?  If that's the case, the report will not longer function. A lot of times, users see a typo in a table or query name, so they rename it, not thinking about the consequences.  If the table or query still exists in the database, try renaming it to the previous name and see if that makes your report work.

23. Take time to further investigate the properties window.  Each control has properties, and there are many properties that can help you customize your report.