Working with tags to hide form items

vapid2323

Scion
Local time
Today, 10:17
Joined
Jul 22, 2008
Messages
217
Hey guys,

I have a Report form thats got all sorts of controls to filter reports the way a user wants to.

I also have a lot of things that need to be hidden or shown based on what radio button a user selects.

This is the code I had before but I know some of the changes i need to make in order to get it working the way I want but I think it still needs help.

Original Code:
Code:
Private Function fHideForCase()
Dim cControl As control
For Each cControl In Me.Controls
        If cControl.Tag Like "btn2" Then cControl = vbNullString
    Next
End Function

Updated Code:
Code:
Private Function fHideForCase()
Dim vVisible As control
For Each vVisible In Me.Controls
        If cControl.Tag Like "h*" Then vVisible = False
     Next
End Function

So I want to find everything on the form that has a tag starting with h and hide it.
 
If you're trying to set the Visible property:

If vVisible.Tag Like "h*" Then vVisible.Visible = False

vVisible refers to the control, not the property. You also used the wrong variable name in the test.
 
Thanks for the help this worked,

Code:
Private Function fHideForCase()
Dim vVisible As Object
For Each vVisible In Me.Controls
        If vVisible.Tag Like "h*" Then vVisible.Visible = False 'This will hide ALL options.
    Next
End Function
 

Users who are viewing this thread

Back
Top Bottom