Page Object

Description

A Page object corresponds to an individual page on a tab control.

Remarks

A Page object is a member of a tab control's Pages collection.

To return a reference to a particular Page object in the Pages collection, use any of the following syntax forms.

Syntax

Description

Pages!pagename

The pagename argument is the name of the Page object.

Pages("pagename")

The pagename argument is the name of the Page object.

Pages(index)

The index argument is the numeric position of the object within the collection.


You can create, move, or delete Page objects and set their properties either in Visual Basic or in form Design view. To create a new Page object in Visual Basic, use the Add method of the Pages collection. To delete a Page object, use the Remove method of the Pages collection.

To create a new Page object in form Design view, right-click the tab control and then click Insert Page on the shortcut menu. You can also copy an existing page and paste it. You can set the properties of the new Page object in form Design view by using the property sheet.

Each Page object has a PageIndex property that indicates its position within the Pages collection. The Value property of the tab control is equal to the PageIndex property of the current page. You can use these properties to determine which page is currently selected after the user has switched from one page to another, or to change the order in which the pages appear in the control.

A Page object is also a type of Control object. The ControlType property constant for a Page object is acPage. Although it is a control, a Page object belongs to a Pages collection, rather than a Controls collection. A tab control's Pages collection is a special type of Controls collection.

Each Page object can also contain one or more controls. Controls on a Page object belong to that Page object's Controls collection. In order to work with a control on a Page object, you must refer to that control within the Page object's Controls collection.

Properties

Application property, Caption property, Column property, ControlTipText property, ControlType property, Enabled, Locked properties, Event properties, EventProcPrefix property, Height, Width properties, HelpContextID, HelpFile properties, InSelection property, IsVisible property, Left, Top properties, Name property, OldValue property, Page, Pages properties, PageIndex property, Parent property, Picture property, PictureData property, PictureType property, Properties property, Section property, ShortcutMenuBar property, StatusBarText property, Tag property, Visible property.

Methods

Requery method (Control or Form object), SetFocus method, SizeToFit method.

Events

Click event, DblClick event, MouseDown, MouseUp events, MouseMove event.

See Also

Controls collection, Pages collection.

Example

The following event procedure enumerates all the controls on each page of a tab control when the user selects that page.

To try this example, create a new form with a tab control named TabCtl0 and set its OnChange property to [Event Procedure]. Paste the following code in the form's module. Switch to Form view and click on the different tabs to enumerate their controls.

Private Sub TabCtl0_Change()
    Dim tbc As Control, pge As Page
    Dim ctl As Control

    ' Return reference to tab control.
    Set tbc = Me!TabCtl0
    ' Return reference to currently selected page.
    Set pge = tbc.Pages(tbc.Value)
    ' Enumerate controls on currently selected page.
    Debug.Print pge.Name & " Controls:"
    For Each ctl In pge.Controls
        Debug.Print ctl.Name
    Next ctl
    Debug.Print
End Sub