parent/child forms

G

Guest

I have several tables that relate to one "ID" table. I want to create action
buttons that open subforms and automatically insert the current ID from the
main form into the subform (example: for the site with ID "Forest Plot 1" I
have tree measurments. If I click on a button to open the tree measurements
form, I don't want to have to retype "Forest Plot 1"). Obviously I could
work with subforms, but I have 7 tables that all relate to the ID table. Is
there a way to establish the same parent/child relationship without a subform?
 
J

Joan Wild

J.K. Smith said:
I have several tables that relate to one "ID" table. I want to
create action buttons that open subforms and automatically insert the
current ID from the main form into the subform (example: for the site
with ID "Forest Plot 1" I have tree measurments. If I click on a
button to open the tree measurements form, I don't want to have to
retype "Forest Plot 1"). Obviously I could work with subforms, but I
have 7 tables that all relate to the ID table. Is there a way to
establish the same parent/child relationship without a subform?

If you stick with subforms, you won't have to type in the ID as that will be
the Link Child/Link Master field.

You could create a main form with tabs, one for each of the subforms, or
just have one subform control and change it's RecordSource at runtime.

Although not unheard of, I have a suspicion that your tables aren't designed
optimally - care to share?
 
J

John Vinson

On Tue, 1 Mar 2005 07:55:05 -0800, "J.K. Smith" <J.K.
I have several tables that relate to one "ID" table. I want to create action
buttons that open subforms and automatically insert the current ID from the
main form into the subform (example: for the site with ID "Forest Plot 1" I
have tree measurments. If I click on a button to open the tree measurements
form, I don't want to have to retype "Forest Plot 1"). Obviously I could
work with subforms, but I have 7 tables that all relate to the ID table. Is
there a way to establish the same parent/child relationship without a subform?

With a subform, no button, no code, and no automatically created new
records are necessary. Why don't you like subforms!? Creating empty
"placeholder" records is very risky; they have a way of never getting
filled in.

I'd suggest using a Tab Control on your main form with seven tab
pages, with a subform on each page.

If you *really* want to do it the hard way, you can use the OpenForm
method in VBA, and pass the ID in the OpenArgs argument of the method;
then use code in each form's Open event to set the default value of
the ID to the value passed in OpenArgs.


John W. Vinson[MVP]
 
G

Guest

I appreciate your comments. I do, in fact, need all 7 tables. Each study
(ie overstory, understory, soil types, percent cover, etc.) is completely
independent, but multiple studies are carried out at any one site. It
obviously doesn't make sense to repeat the site information (UTMs, aspect,
slope, etc) for every single record in each of these tables. My goal was to
establish a main data form that would allow someone who doesn't know Access
to enter the 4 details for the site information (Site name, Treatment,
protocol, plot #) that would establish that this site already exits or this
is a new site and needs a new key (I'm using an autonumber to make life
easier). This autonumber would be inserted into the next form, a "Visit" form
(these sites are monitored every 5 years). Again, they would establish
whether this is in fact a new visit number, or an existing visit number
(years post harvest, data collector name, date, weather, etc.). Another
autonumber (associated with the visit for the particular site) would then be
inserted into any forms that I open while the visit form is open to the
particular site/visit they want. Additionally, I would like to display the
the full site name, visit number in the header, but I think I can do that
with DLookup in SQL.
Again, my focus is all about ease of use. I'm handing this project off to
someone else and I want to make her life as simple as possible. I've seen
this done before, but I don't know what code to use.
You also mentioned the tabs, do you think that would be superior to the plan
I've outlined? I'm not overly familiar with tabs, but I'm assuming there's a
help topic I could use to create something.
Thanks again,
JKS
 
P

PatdeLux

J.K. Smith said:
I have several tables that relate to one "ID" table. I want to create action
buttons that open subforms and automatically insert the current ID from the
main form into the subform (example: for the site with ID "Forest Plot 1" I
have tree measurments. If I click on a button to open the tree measurements
form, I don't want to have to retype "Forest Plot 1"). Obviously I could
work with subforms, but I have 7 tables that all relate to the ID table. Is
there a way to establish the same parent/child relationship without a subform?
I think you could create a query with your main table + your 6
additional table linked to it with a 1 to 1 relationship.
You should change the relationship to use outer join (E.G. Show MainData
and corresponding SpecialData1) in order to have the query return the
Main data even if there is no related data.

Patrick Honorez
www.keyjob.lu
 
J

John Vinson

You also mentioned the tabs, do you think that would be superior to the plan
I've outlined? I'm not overly familiar with tabs, but I'm assuming there's a
help topic I could use to create something.

Yes; I have many forms with a main table related to multiple child
tables, and I routinely use a Tab Control with one or more subforms on
each tab page. It's possible to overdo this (performance can begin to
drag when you have a dozen active subforms!) but it's much simpler and
easier to maintain than using VBA code to open multiple independent,
unlinked forms.

Simply use the Toolbox Wizard to create a Tab Control on your form.
The wizard will ask how many pages; say seven. You can then select
each page in turn, change its Name to something meaningful, and -
*with the page selected and dark* - insert a subform onto it. Don't
drag an existing subform onto the tab control; doing so will put it
"in front of" the tab control so it will show on all pages.


John W. Vinson[MVP]
 

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