Subform Disabled

A

aubrey

Hi,

I have a Form with a Sub-Form.
Is there a code to disable the Sub-Form OnOpen

Any help would be greatly appreciated.

Thanks,
 
D

Dirk Goldgar

aubrey said:
Hi,

I have a Form with a Sub-Form.
Is there a code to disable the Sub-Form OnOpen


What do you mean? Do you want to prevent the subform's Open event from
firing, or do you want to use the main form's Open event to disable the
subform? Or something else? Please explain what you want to do in a little
more detail.
 
A

aubrey

i would like to disable the subform, similar to how you would disable a
field, on open of the mainform. i'm then going to used a command button to
enable the subform when its needed.
 
D

Dirk Goldgar

aubrey said:
i would like to disable the subform, similar to how you would disable a
field, on open of the mainform. i'm then going to used a command button to
enable the subform when its needed.


Then your code for the main form's Open event would be similar to this:

'----- start of example code -----
Private Sub Form_Open(Cancel As Integer)

Me.YourSubformName.Enabled = False

End Sub
'----- end of example code -----

Note that, in the above code, "YourSubformName" must be the name of the
subform *control* on the main form, which may or may not be the same as the
name of the form object that control displays.
 
D

Dirk Goldgar

aubrey said:
i would like to disable the subform, similar to how you would disable a
field, on open of the mainform. i'm then going to used a command button to
enable the subform when its needed.


Come to think of it, why not just set the subform control's Enabled property
to No at design time? You could still use your command button to enable it
later.
 

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