Full Version: A subform within a subform...within a form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Frisco
Hi,

I am working on an employee booking database and am having an issue with one particular component. I am setting up an add customer form (see the enclosed JPG file). As you will see, the customer form has within it a sites subform (each customer could have multiple site addresses). You will also see that the sites subform has within it a contacts subform because each site can have multiple contacts.

Now, when I bring up the form, it is displaying the information as I have entered it through the datasheet view - that is fine. But when I try and enter in new contact information in the subform, it is not working.

My data structure is that the customers table is linked to the sites table through "site ID"; the sites table is linked to a sitecontacts table through "site ID"; and the sitecontact table is linked to the contacts table through "contact ID". I wasn't having any luck in linking the sites table and the contacts table directly to ensure I could get multiple contacts for a site (unless I was doing something wrong).

Now it seems that the problem is in this sitecontact table (which consists of 3 fields, sitecontactID, siteID and contactID. sitecontactID is an autonumber field as is the contactID in the contacts table. My form is trying provide an autonumber for both. But it would seem a must to do so as both must be updated - the sitecontact table provides the relationship between the site and the contact while the contacts table provides the contacts info.

Any suggestions?

Thanks,
Brad.
Jack Cowley
tblCustomers
CustomerID (PK and auto)
LastName
FirstName

tblSites
SiteID (PK and auto)
CustomerID (FK)
...other necessary fields...

tblContacts
ContactsID (PK and auto)
SiteID (FK)
...other necessary fields...

If your tables are set up as above the form/subform/subsubform should work... if the Sites form is in datasheet view you will need to put code in the On Current event to put the SiteID into a hidden control and link the subsubforms Master Link to that hidden control.

hth,
Jack
Frisco
That works PERFECTLY!!! - Thanks Jack - I really appreciate your help.
Jack Cowley
Phew! Glad to hear that was the solution you were looking for... Continued success with the project....

Jack
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.