I have a tab control set up with four pages in it. I want to have a button on page 1 that says "Next" and when you click it, it goes to the next page. I know the command in VB is tabname.tab = 2, but that doesn't work in VBA. Any ideas? Thanks!
I tried that, but it's not working. My four tabs have page indexes 0-3, but DoCmd.GoToPage gives me an error on any number except 1. It says there is no page number 2. What is a page collection?
Here is a piece of code using the page and tab control collections
Dim tbc As control, pge As Page, oldPge As Page
' Return reference to tab control.
Set tbc = Me!TabCtl0
' Return reference to currently selected page.
Set pge = tbc.Pages(tbc.Value)
If you click on one of your tabs and look at properties, does it show the word page in the upper left corner of the properties box. Are you sure you have a tab control?
Yeah, it's definately a tab control. I have named the pages, should I use the names instead of the page indicies? I tried using the above code, but I got an error on the last line at tbc.Value, it says "Object doesn't support this property or method."
Sorry that the reference to the tab control and pages didn't work for you. The error is probably due to not having a reference library set. I am not sure which library since I have a number of libraries set, but the following code works in my Access 2000 program. Here are a couple of reference libraries I have set. Microsoft Access 9.0 Object Library, and Microsoft Visual Basic for Applications Extensibility 5.3
Dim tbc As control, pge As Page, oldPge As Page
' Return reference to tab control.
Set tbc = Me!TabCtl0
' Return reference to currently selected page.
Set pge = tbc.Pages(tbc.Value)
' Check the currently selected page.
If (pge.Name = "Shop Order List" Then
glbLastPage = pge.Name
Exit Sub
Else
'--- Always go to the Equipment form to get the equipment Number
'--- when coming from the shop order
If glbLastPage = "tpShopOrder" Then
tbc.Pages(1).SetFocus
End If
End If
glbLastPage = pge.Name
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.