How to disable all controls in form?

  • Thread starter Thread starter Sam Kuo
  • Start date Start date
S

Sam Kuo

I'd like to disable a large number of controls and enable a small number of
controls (within a frame in a multipage) when click a button.

I'm guessing the quickest way to do this is to disable all controls then
enable the ones I need in code? But I don't know how to disable all controls
in a short way. Any ideas?
 
hi, Sam !
I'd like to disable a large number of controls and enable a small number of controls
(within a frame in a multipage) when click a button.
I'm guessing the quickest way to do this is to disable all controls then enable the ones I need in code?
But I don't know how to disable all controls in a short way. Any ideas?

for sure, it will depend on...
- the number (and type) of controls you need to (dis/en)able
- the layout/location/arrangement/... for these controls
- the conditions to decide which control/s shall be (dis/en)abled
- *IF* you need to control all of the above with a single button
- ???

a quick way could it be Label-controls ABOVE each "group" of controls
(set a "transparent" BackStyle and a "no border" BorderStyle for the Label-controls)
and use your button_events to handle it's .Zorder property (i.e.)

assuming only two goup of controls, each of them with a Label-control ABOVE
and two ToggleButtons to handle the .ZOrder property
try the following lines in your UserForm code module (adapt/modifi/... as needed)

Private Sub UserForm_Initialize()
Label1.ZOrder 0
Label2.ZOrder 0
End Sub
Private Sub ToggleButton1_Click()
Label1.ZOrder -ToggleButton1
ToggleButton1.Caption = IIf(ToggleButton1, "Dis", "En") & "able Group 1"
End Sub
Private Sub ToggleButton2_Click()
Label2.ZOrder -ToggleButton2
ToggleButton2.Caption = IIf(ToggleButton2, "Dis", "En") & "able Group 2"
End Sub

hth,
hector.
 
Hi Hector

Having read through your reply, I came to realise that perhaps it's better
(and easier) for me to disable all multipage tabs other than the one tab in
which the controls needs to be enabled, than to try and disable all controls.

Thanks for your thoughts!

Sam
 
Back
Top