Opening subform on a form

J

JimP

A form has a subform on it. Is it possible to not open the subform at the
time the main form opens, and open the subform when a button on the main
form is pressed?

...easy enough to open a separate form from the button, but not sure how a
subform could be opened (some type of late binding?).
 
L

Larry Linson

JimP said:
A form has a subform on it. Is it possible to
not open the subform at the time the main
form opens, and open the subform when a
button on the main form is pressed?

Not to be picky, but just for the record, there is no Access Object called a
Subform -- there is a Subform Control, usable on a Form, in which you can
embed a Form or Datasheet View. You do not "Open" Controls, and, when
displayed in a Subform Control, the embedded form is not "Open" (it will not
be a member of the "Forms" collection), but is the Form propert of the
Subform Control.

What you can do is to set the Visible Property of the Subform Control so
that it shows or does not.
..easy enough to open a separate form from the button, but not sure how a
subform could be opened (some type of late binding?).

"Late binding"? That does not apply either to Controls or to Forms.

In the Click event of the Command Button,

Me!nameofyoursubformcontrol.Visible = True

So it doesn't show all the time, set the Visible property of the Subform
Control to "No" in design view.

If you'd like to be able to toggle the Visibility On and Off, you could use

Me!nameofyoursubformcontrol.Visible = Not
Me!nameofyoursubformcontrol.Visible

Larry Linson
Microsoft Office Access MVP
 
J

JimP

Thanks, my problem is that the recordsource for the subform does not exist
until the "button" is pressed. But, what you suggest should work along with
a requery of some type.
 

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