Opening a subform in a form

V

VJ

Hi,

I am trying to open a subform on the main form when I select a name from a
combo box. I can make it open as a new page but I would like the subform to
be invisible and then visible pulling the name and other information on the
main page. Is this possible? I am using Access 2000. Please help thanks
 
K

Klatuu

There are two issues here. The subform control which is a control on the
main form and the subform control's source object which identifies which form
is displayed in the subform control.

There are a couple of ways you can approach this.
One would be to set the subform's visible property to No in design view,
then programmatically change it as desired in the main form's code.

The other would be to specify no form name in the subform control's source
object property, but load the subform programmatically. You would still
probably want to use the control's visibility property; otherwise, you would
show an empty control on your main form unless you set the control's boder
property to none and its special effects property to flat.
To load a subform into the control it would be:

Me.MySubformControl.SourceObject = "MySubformName"
 
V

VJ

Ok thanks, I have one other question. I have the main form setup for a person
to pick a venue name and when they click it I want to show the subform
showing the information that correlates to that Venue Name. What code do I
need to make that happen? It's not working with everything I have tried.
Please help. thanks again
 
K

Klatuu

I don't know enough about your from and the record source for the form and
subform.
Is the main form a bound form or is it ust used to select the venue and
perhaps some other controls?
If the main form is a bound form, does it have a field that relates to the
venue?
Does the subform's record source have a field that relates to the venue?
If you can provide some more detail, we can choose the best way to do this
for you.
 
V

VJ

Ok I guess I should start by saying I am building a vendor database. The main
form, Hotel Find, is a bound form. It's just a combo box that lets a user
select a venue name and a clear button. Once they click on which venue they
want I want the subform appear with all the data needed for that venue name.
Actually it (the subform) is a form with a subform on it called hotel
information.
Hotel Information has the Venue name, Address, contact person etc and a
subform on it called Meeting capacity which provides capacity of conference
and meeting rooms. Venue Name is the field that matches up everything.
I hope that is clear. if not let me know.
 
K

Klatuu

Okay, here is what I would do. Since the main form is a bound form and you
can relate the main form and the subform's recordsets using the Venue Name, I
would let Access do all the heavy lifting. In the subform control's
properties, go ahead and set the the Link Master Field and Link Child fields
so that when you select a hotel in the main form, the correct venue record
will be in the subform.
If you want show/hide the subform, You can make the subform visible in the
combo's After Update event. When you hide it again will depend on how you
want it to work.
 
V

VJ

Thanks! It worked. I knew it was something simple but it's just one of those
days. :) Have a good one
 

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