ActiveControl again
Set up a Multipage with 2 pages. Each page had a Frame. Each frame had two
option buttons.
All code is in the userform. So just keep adding on ActionControl as shown
in the second msgbox.
Sub WhichOptionButton()
Dim c As MultiPage
Dim c1 As Page
Dim c2 As Frame
Set c = Me.ActiveControl
If TypeOf c Is MSForms.MultiPage Then
Set c1 = c.SelectedItem
If TypeOf c1 Is MSForms.Page Then
Set c2 = c1.ActiveControl
If TypeOf c2 Is MSForms.Frame Then
Set c3 = c2.ActiveControl
MsgBox c.Name & vbNewLine & _
" " & c1.Name & vbNewLine & _
" " & c2.Name & vbNewLine & _
" " & c3.Name
MsgBox Me.ActiveControl.SelectedItem _
.ActiveControl.ActiveControl.Name
End If
End If
End If
End Sub
Private Sub OptionButton1_Click()
WhichOptionButton
End Sub
Private Sub OptionButton2_Click()
WhichOptionButton
End Sub
Private Sub optOneDay_Click()
WhichOptionButton
End Sub
Private Sub opttwoDay_Click()
WhichOptionButton
End Sub
--
Regards,
Tom Ogilvy
"Geoff" wrote in message
...
To get the control with focus when tabbing through the form. The problem
is
how deep to go with activecontrol. The optionbuttons are within a frame
on a
multipage.
So far I have:
Me.ActiveControl.Name returns "MultiPage1"
Me.MultiPage1.SelectedItem.Name returns "Page1"
Me.MultiPage1.SelectedItem.ActiveControl.Name returns "fraOneDayTwoDay"
but I cannot get to the controls within the frame fraOneDayTwoDay which
are
named as optOneDay and optTwoDay.
Geoff
"Tom Ogilvy" wrote:
What are you actually trying to determine/do?
--
Regards,
Tom Ogilvy
"Geoff" wrote in message
...
Tom
I thought at first that was the solution but by coincidence it was
referencing the same tabindexc of the multipage not the tabindex of
the
frame
control . So i'm still stuck on this.
Geoff
"Geoff" wrote:
Thank you.
Geoff
"Tom Ogilvy" wrote:
You don't need activecontrol:
If Me.MultiPage1.SelectedItem.ActiveControl.Name =
"fraOneDayTwoDay"
Then
If fraOneDayTwoDay.TabIndex = 3 Then
lblOneDayBack.Visible = True
Else
lblTwoDayBack.Visible = True
End If
End If
--
Regards,
Tom Ogilvy
"Geoff" wrote:
The following code fails at line 2 with Object vaiable not set
and I
cannot
find the correct syntax.
The proc refers to 2 optionbutton labels in a frame on a
multipage
hence
needing to use SelectedItem.
If Me.MultiPage1.SelectedItem.ActiveControl.Name =
"fraOneDayTwoDay"
Then
If fraOneDayTwoDay.ActiveControl.TabIndex = 3 Then
lblOneDayBack.Visible = True
Else
lblTwoDayBack.Visible = True
End If
End If
T.I.A.
Geoff
|