Add a page break to a report

ShowAdd a page break by using the page break control

In reports, you use a page break control to mark where you want to start a new page within a section. For example, if you want a report's title page and introductory message printed on separate pages, place a page break in the report header (report header: A report section that is used to place information (such as a title, date, or report introduction) at the beginning of a report.) after the controls that you want to appear on the title page and before the controls for the second page.

  1. Open the report in Design view (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.).
  2. Click the Page Break tool Control in the toolbox (toolbox: A set of tools that is available in Design view for adding controls to a form or report.).
  3. Click where you want to place the page break. Place the page break above or below a control to avoid splitting data in that control.

Microsoft Access marks the page break with a short dotted line on the left edge of the report.

Notes

ShowForce a page break if a condition is met

You can force a page break in a report if a condition is met by setting the Visible property of a page break control in a macro (macro: An action or set of actions that you can use to automate tasks.) or an event procedure (event procedure: A procedure that is automatically executed in response to an event initiated by the user or program code, or that is triggered by the system.).

  1. Open the report in Design view (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.).
  2. Click the Page Break tool Control in the toolbox (toolbox: A set of tools that is available in Design view for adding controls to a form or report.).
  3. Click where you want to place the page break.
  4. Do one of the following:

ShowCreate a macro

  1. Click Properties Button image on the toolbar, and specify a name for the page break control in the Name box.
  2. In the Database window (Database window: In Access 2003 and earlier, the window that appears when a database or project is opened. It displays shortcuts for creating new database objects and opening existing objects. In later versions, it is replaced by the Navigation Pane.), click Macros Button image under Objects.
  3. Click the New button on the Database window toolbar.
  4. In a blank action row (action row: A row in the upper part of the Macro object tab in which you enter macro names, actions, arguments, and comments associated with a particular macro or macro group.), click SetValue in the action list (action list: The list that appears when you click the arrow in the Action column of the Macro object tab.).
  5. Set the Item argument to the identifier (identifier (expressions): An element of an expression that refers to the value of a field, control, or property. For example, Forms![Orders]![OrderID] is an identifier that refers to the value in the OrderID control on the Orders form.) for the Visible property of the page break control. For example, if the name of the control is CondPgBreak, set the Item argument to [CondPgBreak].[Visible].
  6. Set the Expression argument to No.
  7. Click Save Button image to save the macro.
  8. In report Design view (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.), set the OnFormat property of the report's page header (page header: Used to display a title, column headings, dates, or page numbers at the top of every page in a form or report. In a form, the page header appears only when you print the form.) section to the name of the macro.
  9. This hides the page break control when the report starts formatting each page, so the page doesn't break.
  10. Create a second macro that sets the Visible property of the page break control to Yes when a conditional expression (conditional expression: An expression evaluated and compared to a value; for example, If...Then and Select Case statements. If the condition is met, one or more operations are performed. If it isn't met, the operation is skipped.) is met. As you can see from the following example, to make a page break occur if the Counter control in the detail section (detail section: Used to contain the main body of a form or report. This section usually contains controls bound to the fields in the record source but can also contain unbound controls, such as labels that identify a field's contents.) is 10, set the detail section's OnFormat property to the name of the second macro.

Select an action to carry out when a condition that you specify is met

  1. Click Save to save the macro.
  2. Select the section where you placed the page break, and set the section's OnFormat property to the name of the second macro. In the preceding example, to make a page break occur if the Counter control in the detail section is 10, set the detail section's OnFormat property to the name of the second macro.
  3. When the condition (condition: Part of the criteria that a field must meet for searching or filtering. Some conditions must be used with a value; for example, the field Author with the condition equals with the value Jane.) is met, the page breaks. After the page is broken, the macro attached to the page header hides the page break control until the condition is met again.

ShowCreate an event procedure

  1. Double-click the section selector of the page header.
  2. On the Event tab in the property sheet, click the OnFormat property.
  3. Click Build Button image next to the property box to display the Choose Builder dialog box.
  4. Double-click Code Builder to display the event procedure Sub and End Sub statements in the report module (report module: A module that includes Visual Basic for Applications (VBA) code for all event procedures triggered by events occurring on a specific report or its controls.).
  5. In the event procedure, add an assignment statement that sets the Visible property of the page break control to No. For example, if the name of the control is CondPgBreak, add the following assignment statement:
Me![CondPgBreak].Visible = False
                              

This hides the page break control when the report starts formatting each page, so the page doesn't break.

  1. In the Format event procedure of the section where you placed the page break, add Microsoft Visual Basic (Microsoft Visual Basic: A high-level, visual-programming version of Basic. Visual Basic was developed by Microsoft for building Windows-based applications.) code that sets the Visible property to Yes when a condition (condition: Part of the criteria that a field must meet for searching or filtering. Some conditions must be used with a value; for example, the field Author with the condition equals with the value Jane.) is met. For example, to make the detail section (detail section: Used to contain the main body of a form or report. This section usually contains controls bound to the fields in the record source but can also contain unbound controls, such as labels that identify a field's contents.) break when the value of the Counter control reaches 10, add the following code to the Detail_Format event procedure:
If Me![Counter] = 10 Then
 Me![CondPgBreak].Visible = True
End If
                              
 
 
Applies to:
Access 2003