Page, Pages Properties

Applies To   Form, Report, Tab control.

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.

  • The Page property specifies the current page number when a form or report is being printed.
  • The Pages 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 Visual Basic.

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. To test this example, paste the following code into the Page Event for the Alphabetical List of Products form.

Dim intTotalPages As Integer, strMsg As String
intTotalPages = Me.Pages
strMsg = "This report contains " & intTotalPages & " pages."
MsgBox strMsg