Tom van Stiphout wrote:
On 13 Nov 2006 11:59:05 -0800, pi********@hotmail.com wrote:
Perhaps you could write:
dim varControls as Variant = Array("cmbBox1","cmbBox2","cmbBox3")
dim varControl as Variant
for each varControl in varControls
Me.Controls(varControl).Visible = False
next varControl
or if you KNOW the controls are numbered successively:
dim i as Integer
for i = 1 to 3
Me.Controls("cmbBox" & i).Visible = False
next i
There is also an interesting way to do it with additional parameters
passed to a function. I'll leave it up to you to read up on
ParamArray.
-Tom.
I like Tom's ideas. Here's a way to set the Visible property of all
comboboxes on an A97 form to False:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acComboBox Then
With Controls(ctl.Name)
.Visible = False
End With
End If
Next ctl
You can set the Tag property to a value and use that to control which
comboboxes disappear:
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.ControlType = acComboBox Then
Select Case Me.Controls(ctl.Name).Tag
Case "HideMe":
With Controls(ctl.Name)
.Visible = False
End With
End Select
End If
Next ctl
Try not to double up on the Tag property. You won't like where that
road leads. Ditto for OpenArgs.
Dim ctl As Control
For Each ctl In Me.Controls
If Right(ctl.Name, 9) = "Ephemeral" Then
If ctl.ControlType = acComboBox Then
With Controls(ctl.Name)
.Visible = False
End With
End If
End If
Next ctl
sets the Visible property of comboboxes with a name ending in Ephemeral
to False.
It's also possible to use other combobox properties such as ForeColor,
which can have values that are just about indistinguishable from each
other. Each shade variation can identify a group of controls. Groups
of control groups can use a color difference metric, say R,G and B
being within one unit of a particular color. I hope this helps.
James A. Fortune
CD********@FortuneJames.com
A proverb is no proverb to you till life has illustrated it. -- John
Keats