Not only can you create and manipulate report sections at design time, you also can do so at runtime. You must first open the report in Design view. You use the DoCmd object to add a report header and footer or a page header and footer. The code appears in Listing 10.11.
You can also add section headers and footers. The code in Listing 10.12 illustrates the process. It is found in frmReportSections on the sample code CD.
Note that the CreateGroupLevel function receives four parameters. The first is the name of the report you want to affect. The second is an expression designating the expression on which the grouping is based. The third parameter allows you to specify whether you want the group to have a group header, and the final parameter lets you designate whether you want to include a group footer.