Class Pages (Access VBA)
The Pages collection contains all Page objects in a tab control. To use a Pages class variable it first needs to be instantiated, for example
Add
The Add method adds a new Page object to the Pages collection of a tab control.
The first Page object in the Pages collection corresponds to the leftmost page in the tab control and has an index of 0. The second Page object is immediately to the right of the first page and has an index of 1, and so on for all the Page objects in the tab control. If you specify 0 for the Before argument, the new Page object is added before the first Page object in the Pages collection. The new Page object then becomes the first Page object in the collection with an index of 0. You can add a Page object to the Pages collection of a tab control only when the form is in Design view.
Add (Before)
Before: An Integer that specifies the index of the Page object before which the new Page object should be added. The index of the Page object corresponds to the value of the PageIndex property for that Page object. If you omit this argument, the new Page object is added to the end of the collection.
Function AddPage() As Boolean
Dim frm As Form
Dim tbc As TabControl, pge As Page
On Error GoTo Error_AddPage
Set frm = Forms!Form1
Set tbc = frm!TabCtl0
tbc.Pages.Add
AddPage = True
Exit_AddPage:
Exit Function
Error_AddPage:
MsgBox Err & ": " & Err.Description
AddPage = False
Resume Exit_AddPage
End Function
Count
You can use the Count property to determine the number of items in a specified collection.
CreateControl.Pages.Count
Item
The Item property returns a specific member of a collection either by position or by index.
If the value provided for the Index argument doesn't match any existing member of the collection, an error occurs. The Item property is the default member of a collection, so you don't have to specify it explicitly. For example, the following two lines of code are equivalent.
Item (Index)
Index: An expression that specifies the position of a member of the collection referred to by the expression argument. If a numeric expression, the Index argument must be a number from 0 to the value of the collection's Count property minus 1. If a string expression, the Index argument must be the name of a member of the collection.
Debug.Print Modules(0)
Remove
The Remove method removes a Page object from the Pages collection of a tab control.
The Pages collection is indexed beginning with zero. The leftmost page in the tab control has an index of 0, the page immediately to the right of the leftmost page has an index of 1, and so on. You can remove a Page object from the Pages collection of a tab control only when the form is in Design view.
Remove (Item)
Item: An integer that specifies the index of the Page object to be removed. The index of the Page object corresponds to the value of the PageIndex property for that Page object. If you omit this argument, the last Page object in the collection is removed.
Function RemovePage() As Boolean
Dim frm As Form
Dim tbc As TabControl, pge As Page
On Error GoTo Error_RemovePage
Set frm = Forms!Form1
Set tbc = frm!TabCtl0
tbc.Pages.Remove
RemovePage = True
Exit_RemovePage:
Exit Function
Error_RemovePage:
MsgBox Err & ": " & Err.Description
RemovePage = False
Resume Exit_RemovePage
End Function