Question : Refer to page in tab control by name

I have a form called "frmGuardian" with has a tab control in it. The tab control is called "TabCrtlGuardian"

Also on the form is a command button which opens a pop up form. Once the user has selected a record in the pop up form I need to know which page in the tab control is current. I can reference to page's index but am worried that this might change during development, so I would rather reference the name of the tab. I read that the way to do this is as follows:

Select Case Forms!frmGuardian.Form.TabCrtlGuardian.Value
Case Forms!frmGuardian.Form.TabCrtlGuardian.pgeTrave.PageIndex
do what I want to do....

case ......
end select

The select case statement gives me the correct value but the

Case Forms!frmGuardian.Form.TabCrtlGuardian.pgeTravelToDerwen.PageIndex

returns an error 438 - object doesn't support this property or method

What am I doing wrong?

Answer : Refer to page in tab control by name

Here is some code that works with the page names of a Tab control:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
Private Sub tabSettings_Change()
'Created by Helen Feddema 19-Nov-2009
'Last modified by Helen Feddema 19-Nov-2009

On Error GoTo ErrorHandler

   Dim tbc As Access.TabControl
   Dim pge As Access.Page
   Dim strPage As String
   
   Set tbc = Me![tabSettings]
   Set pge = tbc.Pages(tbc.Value)
   strPage = pge.Name
   
   Select Case strPage
      Case "pgeOne"
         'Your code here
         
      Case "pgeTwo"
         'Your code here
      
      Case "pgeThree"
         'Your code here
      
   End Select
   
ErrorHandlerExit:
   Exit Sub

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in tabSettings_Change procedure" _
      & "; Description: " & Err.Description
   Resume ErrorHandlerExit

End Sub
Random Solutions  
 
programming4us programming4us