Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling frames on forms

Status
Not open for further replies.

meltdown

Programmer
May 1, 2002
7
0
0
CA
I want to be able to disable an entire frame in a particular form. The frame may contain other frames. Can it be done ? how ?
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top