View Full Version : Aargh! Sub-forms!


PeteUK
08-29-2001, 01:27 AM
Hi. Hope someone can help please. Basically I have a main form consisting of client details with CustomerID being the primary key. Now, on this form I have three sub-forms which all relate to the main record, but are just different sections - i.e. Network details, Trading details etc. What I want to be able to do, is allow the user to make as many records on the sub form as they like - but only specific to the main record. So when they go to a different customer, the sub forms are either blank or have data relating to that record.

What I have at the moment, is I insert some information on one of the sub forms, but when you leave the record / database it disappears from the sub form and I would like data there permanently.

I hope I have explained myself clear enough. Thanks.

Pete

Laocon
08-29-2001, 02:02 AM
Hi There,

Im pretty new with Access but here is my take on your setup...

I can show you it best with an example:

You will need to have 4 tables with the following info...

TABLE 1
CustomerID
CustomerName
CustomerAddress

TABLE 2
CustomerID - Lookup to TABLE 1
NetworkID
NetworkName
NetworkDetails

TABLE 3
CustomerID - Lookup to TABLE 1
TradingID
TradingName
TradingDetails

TABLE 4
CustomerID - Lookup to TABLE 1
PaymentID
PaymentAmount
PaymentDate

As you can see CustomerID is in every table and looks-up the value to be stored from TABLE 1 (when choosing your Look-up, choose CustomerName and CustomerID - hide ID column; that way on entering the data you choose a CustomerName but it stores the ID =) hehe)

Now make 3 forms for TABLES 2 thru 4.

Now... use a form wizard to make a Form for table 1 - then go into design view and add a subform pointing to each of the subforms in turn - choose CustomerID as the related field for each one.

Now when you browse the records you are browsing through the customerIDs and each time you move through - it should update all the subforms appropriately http://www.access-programmers.co.uk/ubb/smile.gif

HTH

As I say - this may not be exactly what you want - I am new with access myself http://www.access-programmers.co.uk/ubb/smile.gif

--------
Laocon

Rich
08-29-2001, 04:26 AM
Check out some of the sample databases supplied by Microsoft for examples of how to set up One to Many relationships i.e. "Northwind","Orders" and "Solutions"
HTH