K
Kirk Wilson
I found a code snippet in help that lists all controls on a tab control.
For Each ctlCurrent In tabCtl
Debug.Print ctlCurrent.Name
Next ctlCurrent
I modified the code to return a control by its index
For I = 0 To 15
Debug.Print tabCtl!ctlCurrent(I).Name
Next I
This creates a type mismatch runtime error
How do I correct this error? Full code listing follows:
frmMonth24 is the main form.
tabForm is a tabcontrol on frmMonth24
Public Function GetPageName()
Dim tabCtl As TabControl
Dim ctlCurrent As Control
Dim I As Integer
On Error GoTo ErrorHandler
' Return reference to tab control on Employees form.
Set tabCtl = Forms!frmMonth24!tabForm
' List all controls on the tab control in the Debug window.
' For Each ctlCurrent In tabCtl
' Debug.Print ctlCurrent.Name
' Next ctlCurrent
For I = 0 To 15
Debug.Print tabCtl!ctlCurrent(I).Name
Next I
Set tabCtl = Nothing
Set ctlCurrent = Nothing
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function
For Each ctlCurrent In tabCtl
Debug.Print ctlCurrent.Name
Next ctlCurrent
I modified the code to return a control by its index
For I = 0 To 15
Debug.Print tabCtl!ctlCurrent(I).Name
Next I
This creates a type mismatch runtime error
How do I correct this error? Full code listing follows:
frmMonth24 is the main form.
tabForm is a tabcontrol on frmMonth24
Public Function GetPageName()
Dim tabCtl As TabControl
Dim ctlCurrent As Control
Dim I As Integer
On Error GoTo ErrorHandler
' Return reference to tab control on Employees form.
Set tabCtl = Forms!frmMonth24!tabForm
' List all controls on the tab control in the Debug window.
' For Each ctlCurrent In tabCtl
' Debug.Print ctlCurrent.Name
' Next ctlCurrent
For I = 0 To 15
Debug.Print tabCtl!ctlCurrent(I).Name
Next I
Set tabCtl = Nothing
Set ctlCurrent = Nothing
ErrorHandler:
MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description
End Function