Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

tab control 4

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
US
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!
 
DoCmd.GoToPage (4)

There is also a pages collection if you want to check it out.

 
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."
 
Hi,
The only way I've found to do this (I usually make the user select the tab they want) is to ust the tab names and setfocus:


myTab.SetFocus
 
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
 
The correct syntax is the following:

Tabname.value=0 ' open first page
Tabname.value=1 ' open second page

You can use this property also to check which page is currently open.
 
Sorry, I forgot to write the function for the Next-button (it switches from the 4th page (value=3) to the first page (value=0):

sub NextButton()
dim lngMaxPages as long
lngMaxPages=4

if tabName.value<(lngMaxpages-1) then
tabname.value=tabName.value+1
else
tabName.value=0
end if

end sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top