Disabling SubForm

  • Thread starter Thread starter Nigel
  • Start date Start date
N

Nigel

On my mainform, frmEmployees, I have a control called Status. I have
successfully managed to disable all the other ontrols on the form by tags and
using the following code when the staus of a person is "C":
Dim ctrl As Control
If Status = "C" Then
For Each ctrl In Me.Controls
If ctrl.Tag = "Grey" Then
ctrl.Enabled = False
End If
Next
Else
For Each ctrl In Me.Controls
If ctrl.Tag = "Grey" Then
ctrl.Enabled = True
End If
Next
End If
What I also want to do is is to disable the controls on the subform, or
indeed the whole subform, frmDetails. I'm totally confused as to what to
write and where to put the code.

Any help would be appreciated
Thanks
 
Nigel said:
On my mainform, frmEmployees, I have a control called Status. I have
successfully managed to disable all the other ontrols on the form by tags
and
using the following code when the staus of a person is "C":
Dim ctrl As Control
If Status = "C" Then
For Each ctrl In Me.Controls
If ctrl.Tag = "Grey" Then
ctrl.Enabled = False
End If
Next
Else
For Each ctrl In Me.Controls
If ctrl.Tag = "Grey" Then
ctrl.Enabled = True
End If
Next
End If
What I also want to do is is to disable the controls on the subform, or
indeed the whole subform, frmDetails. I'm totally confused as to what to
write and where to put the code.

Any help would be appreciated
Thanks

Me.SubformControlName.Enabled = False

That's the name of the subform control on your main form, the one that
contains the subform.
Where you put the code depends on when and why you want the subform
enabled/disabled.
 
Hi Stuart

Many thanks for your reply. I want the subform to be disabled if the status
on my mainform = "C". Basically, if this person has a staus of "C", both form
and subform are disabled, apart from the status control.

Hope this makes sense.

Nigel
 
Back
Top