Page, Pages Properties

Applies To

Form, Report.

Description

You can use the Page and Pages properties to return information needed to print page numbers in a form or report. For example, you could use these properties to print “Page n of nn” in the page footer of a report.

  • Page — This property specifies the current page number when a form or report is being printed.
  • Pages — This property specifies the total number of pages in a form or report.

Setting

Although you can set the Page property to an Integer value, you most often use these properties to return information about page numbers. Both properties return an Integer value when used in an expression.

You can use the Page and Pages properties in an expression, a macro, or an event procedure.

These properties are only available in Print Preview or when printing.

The Pages property is read-only at all times.

Remarks

To refer to the Pages property in a macro or Visual Basic, the form or report must include a text box whose ControlSource property is set to an expression that uses Pages. For example, you can use the following expressions as the ControlSource property setting for a text box in a page footer.

This expression

Prints

=Page

A page number (for example, 1, 2, 3) in the page footer.

="Page " & Page & " of " & Pages

“Page n of nn” (for example, Page 1 of 5, Page 2 of 5) in the page footer.

=Pages

The total number pages in the form or report (for example, 5).


See Also

PageHeader, PageFooter Properties.

Example

The following example displays a message that tells how many pages the report contains. For this example to work, the report must include a text box for which the ControlSource property is set to the expression =Pages.


Dim intTotalPages As Integer, strMsg As String= Reports![Report1].Pages= "This report contains " & intTotalPages & " pages."strMsg