Disabled Subform Logic Runs Anyway

B

Bill Sturdevant

I have a main form with multiple subforms.

At various times, I disable some of the subforms.

Even though a subform is disabled, its Form_Open and
Form_Current routines run anyway!

I am startled by this. Am I doing something wrong?

I know I can check a flag and if it is set, then exit the
Form_Open and Form_Current, but it seems like they should
not run since the whole subform is disabled on the main
form.

Can anyone explain this?
 
P

Pavel Romashkin

What do you mean, Disabled?
I believe if you remove the name of the subform from the subform
control's data source then that subform will stop running. If you simply
hide it and leave its child/parent links intact, it will keep running in
the background.
Pavel
 
J

John Vinson

I have a main form with multiple subforms.

At various times, I disable some of the subforms.

Even though a subform is disabled, its Form_Open and
Form_Current routines run anyway!

I am startled by this. Am I doing something wrong?

I know I can check a flag and if it is set, then exit the
Form_Open and Form_Current, but it seems like they should
not run since the whole subform is disabled on the main
form.

Can anyone explain this?

The Subforms actually are opened BEFORE the mainform opens.

To thoroughly disable a Subform, set its SourceObject property to null
(removing the Form from the subform entirely).
 
G

Graham Mandeno

Hi Bill

Enabled=False (No) simply means that the user cannot set focus to the
subform in that control. Note that it is not a property of the subform
itself, but only of the control that *contains* the subform.

If the subform knows the name of its container control, then you can check
its Enabled property and take appripriate action. For example:

If Me.Parent![Subform control].Enabled = False Then Exit Sub
 

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