Okay so there is nothing really fancy here, I just find myself using this sub all the time and thought some other people might find it useful. It loops through all the controls in a given form and sets their visibility value depending on whether the last character(s) match the tag passed in. The idea here is that, rather than having to write Me.controlName.Visible = True (False) for each control, you can just add a common label to the names of a block of controls (I like "_A" or "_1") that you wish to make either visible or invisible depending on circumstances in your form. There's the code:
Code:
Public Sub visibleControl(formName As String, visTag As String, Vis As Boolean)
' This subroutine is used to set the Visible property on form controls based
' on the visTag string.  This assumes the controls to be modified all have the visTag
' string as the last part of the control name.
    Dim myForm As Form, ctrl As control, lenTag As Integer
        
        Set myForm = Forms(formName)
        lenTag = Len(visTag)
        
        For Each ctrl In myForm.Controls
            If Right(ctrl.name, lenTag) = visTag Then
                ctrl.Visible = Vis
            End If
        Next ctrl
End Sub
Let me know if you have any trouble implementing or if you just find it useful.


Cheers,