Defining the Grouping and Sorting Criteria

The next thing you need to do is define the grouping and sorting criteria for the report. Click the Group & Sort button in the Grouping & Totals group on the Design tab to open the Group, Sort, And Total pane. This report should display the daily reservation data from the query in the Detail section, with summaries of reservations by room number, by date, and by facility. Note that in the Group, Sort, And Total pane, you specify grouping values from the outermost to the innermost (like specifying a sorting criteria left to right). So, select the FacilityName sorting specification in the first line of the Group, Sort, And Total pane, click More to expand the options, click the arrow on the Without A Footer box, and then click With A Footer Section. Notice that when you add a group header or group footer for any field or expression in the Group, Sort, And Total pane, Access 2010 adds an appropriate section to your report. Access also changes this specification from Sort By to Group On. You want to make sure that a group header doesn’t get “orphaned” at the bottom of a page, so click the arrow on the option that says Do Not Keep Group Together On One Page and click Keep Header And First Record Together On One Page. Note that you can also ask Access to attempt to keep all the detail for this level of grouping on one page by clicking the Keep Whole Group Together On One Page option. When you do this, Access will produce a new page if all the detail for the next group won’t fit on the current page. As you’ll see later, the report sections also have properties that you can set to force a new page with the start of each group.

The DateValue field from the query returns the date each room is occupied across a reservation span. When housing managers review reservations for more than one month, they might want to see subtotals by month. You can create a group on month by clicking the DateValue sorting specification, clicking More to expand the options, clicking the arrow on the group on property box (where it says By Entire Value), and clicking By Month. See the sidebar Understanding Grouping Options, for details about other options you can set. Also, click the arrow on the group footer property (where it says Without A Footer Section), and click With A Footer Section to create a space to place monthly totals on your report. (Notice that Access changes this specification from Sort By to Group On.) Click the arrow on the option that says Do Not Keep Group Together On One Page, and click Keep Header And First Record Together On One Page, as you did for the FacilityName grouping specification.

You can include the DateValue field in the Group, Sort, And Total pane again, but set the group interval to Each Value to create a subtotal by day. Click Add A Group to create a blank specification row for a second DateValue. Click DateValue in the Select Field box, click More to see all the options, click the arrow on the group interval box (where it says By Quarter), and then click By Entire Value. Next, click Without A Header Section in the header section box, and click With A Footer Section in the footer section box. Finally, click Keep Whole Group Together On One Page for the last option so that a set of rows for a particular day doesn’t split across a page boundary. You need to move this new grouping specification up one level in the grouping and sorting order, so click the Move Up arrow to move this second DateValue group specification above the RoomNumber sort specification. Remember that there’s no sorting specification in the query you built or in the sample qryXmplRptReservationsByDay query. There wouldn’t be any point in defining a sort in the query because reports ignore any sorting specification from the query when you define any criteria in the Group, Sort, And Total pane. Your result should look something like that shown in Figure 18-4. (Note that we clicked the first DateValue grouping specification so that you can see the group property settings for that field.)

Set your grouping and sorting criteria for the Facility Occupancy By Date report in the Group, Sort, And Total pane.

Figure 18-4. Set your grouping and sorting criteria for the Facility Occupancy By Date report in the Group, Sort, And Total pane.

Your report design should now look like Figure 18-5.

The Facility Occupancy By Date report has new Footer sections after you define the grouping and sorting criteria.

Figure 18-5. The Facility Occupancy By Date report has new Footer sections after you define the grouping and sorting criteria.

Click Save again to preserve your work to this point. You can find this stage of the report design saved as rptXmplFacilityDateOccupancyStep1 in the sample database.