Disabling SubForm

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
 
S

Stuart McCall

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.
 
N

Nigel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top