Hide "Grouped" Controls

M

Michael

Hi Folks - I have 15 controls (labels, text boxes and lines) that I would
like to hide for a certain set of criteria. I know I can set each control's
visible property to false, but I'm wondering if there is a way to 'group'
the controls together, then just hide the group. Any ideas? Thanks.

Michael
 
J

John Spencer

You can use the TAG property and give each of the controls you want to
show/hide the same tag. Then you can loop through the controls, check the
tag value and show or hide that way.

'UNTESTED AIRCODE (with no error handling)

Private Sub sShowStuff(Optional tfShow as Boolean = True)
Dim ctlAny as Control

For Each CtlAny in Me.Controls
If CtlAny.Tag = "ShowStuff" Then
CtlAny.Visible = tfShow
End if
Next ctlAny

End Sub

Then all you need to do is call sShowStuff with True or False

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top