simple question - change multiple controls

svenhoek
04-14-2003, 06:12 PM
I'm sure this is a very simple thing that I SHOULD know the answer to, but...

What's wrong with this code?

Private Sub cmdemployment_Click()
For Each Control In frmvision
If Control.Type = Frame Then
Control.Visible = False
End If
Next Control
fraemploy.Visible = True
End Sub

I have a form with multiple frames and I want each command button to hide all the other forms and only show one.

Thanks!

Squirm
04-14-2003, 06:53 PM
Maybe you're wanting:

For Each Control In frmVision
If TypeOf Control Is Frame Then Control.Visible = False
Next Control

Robse
04-14-2003, 07:12 PM
I have a form with multiple frames and I want each command button to hide all the other forms and only show one.


You want to hide the other forms or the other frames?
Suppose you wanted to hide the other frames.
The easiest way to do this would be to use a control array of
Frames. This way you could traverse the array and set all
Frames' visible properties to false:


Dim n As Integer
For n = 1 To UBound(YourFrame)
YourFrame(n).Visible = False
Next n
YourFrame(x).Visible = True


where x is the index of the Frame you want visible.

svenhoek
04-14-2003, 07:15 PM
Maybe you're wanting:

For Each Control In frmVision
If TypeOf Control Is Frame Then Control.Visible = False
Next Control


Thanks!! I knew it was simple, I just couldn't get it quite right.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum