Recursively enable or disable controls in
frames
This sub calls itself to recursively enable or disable controls in nested
frames. This is much easier then going through by hand if you have several nested frames
with controls in. For example:
EnableFrame fraMyFrame, True
This code will enable all controls in
fraMyFrame.
Procedure
Public Sub EnableFrame(InFrame As Frame, ByVal Flag As
Boolean)
'Recursive routine to
'set the enable property for all controls inside
'nested frames to true or false Dim Contrl As
Control
On Error Resume Next 'not all controls have a container property
InFrame.Enabled = Flag
For Each Contrl In InFrame.Parent.Controls
If Contrl.Container.Name = InFrame.Name Then
If (TypeOf Contrl Is Frame) And Not (Contrl.Name = InFrame.Name) Then
EnableFrame Contrl, Flag 'repeat for nested frame
Else
Contrl.Enabled = Flag
End If
End If
Next End Sub
|