MultiPage Parent Name
John,
Tried your solution and it worked like a charm.
Thanks,
John
"John Green" wrote in message
...
John,
I have to revise my statement. The parent of a control in the multipage is
the page it is in. However, the controls are still in the collection of
controls in the userform. The following code iterates through every
control
on the form:
Private Sub CommandButton1_Click()
Dim ctl As Control
For Each ctl In Me.Controls
MsgBox ctl.Name & ":" & ctl.Parent.Name
Next ctl
End Sub
Each page has its own collection of controls. The following code iterates
through all the controls on a page:
Private Sub CommandButton3_Click()
Dim ctl As Control
For Each ctl In MultiPage1.Page1.Controls
MsgBox ctl.Name & ":" & ctl.Parent.Name
Next ctl
End Sub
There isn't a collection of controls for the multipage object. The
following
code iterates through all the controls in the pages of the multipage:
Private Sub CommandButton4_Click()
Dim ctl As Control
Dim pg As Page
For Each pg In MultiPage1.Pages
For Each ctl In pg.Controls
MsgBox ctl.Name & ":" & ctl.Parent.Name
Next ctl
Next pg
End Sub
--
John Green
Sydney
Australia
"John Wilson" wrote in message
...
John,
OCMC is the UserForm name.
The CheckBoxes were on the UserForm and the code worked fine.
I added a Multpage object and moved the CheckBoxes onto it.
Did'nt think much about it until the code crashed.
Moved the boxes off the multipage and everything worked fine again.
Tried some different manipulations of code using what I thought was the
"Parent" name of the Multipage form, but still couldn't get it to work.
John
"John Green" wrote in message
...
What is OCMC? If it is a reference to your multipage object, the code
will
not work. If it is a reference to your userform, it should work because
the
controls in the multipage are still considered to have the form as
their
parent object.
--
John Green
Sydney
Australia
"John Wilson" wrote in message
...
Due to screen space limitations I had to move a group of CheckBoxes
from MY UserForm onto a MultiPage on that UserForm.
The code that I used to extract info from the CheckBoxes is as
follows:
Dim ctl As Control
For Each ctl In OCMC.Controls
If TypeName(ctl) = "CheckBox" Then
If ctl.Value = True Then
cbResult = cbResult & VBA.Left(ctl.Caption, 3)
End If
End If
Next ctl
Been trying, but can't seem to modify this to work with the CheckBoxes
on the MultiPage Control (there are three pages on the multipage and
I'd
like to address all of them).
Any ideas?
Thanks,
John
|