Pages Property
Pages property as it applies to the Form and Report objects.
You can use the Pages property to return information needed to print page numbers in a form or report. Read/write Integer.
expression.Pages
expression Required. An expression that returns one of the above objects.
Remarks
You can use the Pages properties in an expression, a macro, or Visual Basic.
This property is only available in Print Preview or when printing.
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). |
Pages property as it applies to the Control and TabControl objects.
Returns the number of pages in a control that supports tabbed pages (for example, a TabControl object). Read-only.
expression.Pages
expression Required. An expression that returns one of the above objects.
Example
As it applies to the Form and Report objects.
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
Dim strMsg As String
intTotalPages = Me.Pages
strMsg = "This report contains " & intTotalPages & " pages."
MsgBox strMsg
As it applies to the Control and TabControl objects.
The following example displays a message indicating the number of tabbed pages on tab control TabCtl1.
MsgBox "Number of pages in TabCtl1:" & TabCtl1.Pages.Count