Use a "for each" loop to cycle through each of the controls in your form, that are contained inside your target frame.
Dim Item As Control
For Each Item In Controls
If Item.Container Is Frame1 Then
If Not TypeOf Item Is Label And Not TypeOf Item Is Line Then
Item.Enabled = False
End If
End If
Next Item
You may need to modify the line that checks for the type of controls that you have in your frames. Some controls ( like lines and labels ) do not have an enabled property, so if you do not trap these out you will get an error when you try and disable them.
You don't need to loop thru the controls collection if your desire is to disable all of the controls contained on a frame. To disable all of them, simply disable the frame.
fraFrame.Enabled = False
This will disable all of the controls which have this frame as its container.
If you want to selectively disable the controls (some of them but not all of them), then you would need to loop thru the controls collection to disable those that you need to. Remember tho, to keep the frame enabled in this case.
Good Luck
-------------- As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
Disabling a frame is different from disabbling all the controls in a frame. Disabled text boxes are greyed but text boxes in disabled frames are not. For this reason you may need to loop through the controls to get the results you require.
If you have frames within frames then you need to loop back through container objects until you either reach the form or the frame you were interested in.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.