controls in tabs

J

Jason

Hi,

I have this code which populates values in comboboxes. The problem is
that i want it to do it only in comboboxes within the pages of a
tabcontrol. Is this possible?

Here's the codesnippet:

For Each ctl In Me.Controls
With ctl
If .ControlType = acComboBox Then
Me.Controls(.Name).RowSourceType = "Value List"
Me.Controls(.Name).RowSource = <result of some function>
End If
End With
Next
 
B

Brendan Reynolds

Tab pages have their own Controls collection, containing only controls on
that tab page. So you can do something like this ...

Dim ctlParent As Control
Dim ctlChild As Control

For Each ctlParent In Me.Controls
If ctlParent.ControlType = acPage Then
For Each ctlChild In ctlParent.Controls
If ctlChild.ControlType = acComboBox Then
ctlChild.BackColor = vbRed
End If
Next ctlChild
End If
Next ctlParent
 
J

Jason

Brendan said:
Tab pages have their own Controls collection, containing only controls on
that tab page. So you can do something like this ...

Dim ctlParent As Control
Dim ctlChild As Control

For Each ctlParent In Me.Controls
If ctlParent.ControlType = acPage Then
For Each ctlChild In ctlParent.Controls
If ctlChild.ControlType = acComboBox Then
ctlChild.BackColor = vbRed
End If
Next ctlChild
End If
Next ctlParent
Hi Brendan,

Thnx! That did the job!
 
Top