OK, to do this in subforms, you really don't need to create relationships in
the Relationships window; creating subforms via the Access wizard will
automatically link the data for you properly. Let's start with a 3-tiered
system and you can extend it further.
First, start with the data table at the bottom of the hierarchy. In this
example, I'm going to use tblBedrooms. In this table, make sure you have a
foreign key (FK) field called ApartmentID; this establishes the relationship
between a particular BedroomID and a specific apartment. Create a simple
tabular form for tblBedrooms. Open it and make sure it works. You should
have no problems here.
Second, create a form for tblApartments. Make sure this table has a FK field
called SiteID (and naturally its own ApartmentID); this is used to tie a
specific apartment to a site in step three. Create a simple tabular form for
tblApartments. In this form's design mode, drag and drop the form you
created for tblBedrooms. You'll be asked to specify the parent/child field.
This is ApartmentID since you want Access to synchronize the bedroom records
with the current apartment. Save the form and open it. Use it and make sure
you understand what's going on. When you go to a specific apartment, you'll
see the bedrooms linked to that apartment. If you need to add a bedroom,
just do so in the subform. Leave that apartment and go back to it. You'll
see that the bedroom and the apartment have been effortlessly linked (via
ApartmentID).
Third, create a form for tblSites. In design mode for this form, drag and
drop the second form you created for apartments. Indicate that the
parent/child field should be SiteID. That's it. The apartment subform
should work within the sites form just like the bedrooms subform works for
the apartment form.
Continue doing this up to the top level of the hierarchy. I wouldn't do this
with too many levels simply because the form will be very complicated. Also,
this only works with one to many relationships. In other words, a site
cannot belong to more than one vendor but a vendor may own multiple sites.
hth
Thank you for your great reply. It clarified some stuff, but... I am
working on a form with at least one subform.
I have a table of vendors (and vendor ID). The vendors have multiple sites
(and site ID). i have those two tables and they are filled with data. Each
site has an undetermined number of apartments ( I don't know how many until
my inspectors go out), and lastly, each apartment has an undetermined number
of bedrooms and the number of beds in each bedroom has to be noted.
So I need to collect an autonumber for each apartment at a site. And I need
to collect an autonumber for each bedroom at an apartment.
I need each apartment the inspector notes in the form to get an automatic
unique number, but if it's an autonumber, it won't relate to any of the
fields in the other tables because it is not the same data type. --
Thanks
Do you not get how to do it or do you not get why you do it or both? What
training did you go through? I found that the Northwind database was very
[quoted text clipped - 35 lines]
help fields and I am not getting it.
Thanks