Sub Form Question?

  • Thread starter Thread starter Andrew
  • Start date Start date
A

Andrew

I have two tables in Access;
1. Members
2. Address

The main form is linked into the Members Table & the Address is linked
into the sub form.

The members table has a field to store the address ID this being
relationship in linking them together.

My problem is when entering a new member with a new address; I need
help in writing code or something to copy the new address ID to the
address ID field in the members form so the both link.

The tables are set up this way as you can have many members at the
same address for example family members etc.

You can also email me your answer to (e-mail address removed)
 
No need for code. Use the Link Master Fields and Link Child Fields
properties of the subform control to link the fields (put the name of the
fields in those properties: Master = field name on main form; Child = field
name on subform). Then, as you enter a new record on the main form, the
subform will automatically enter the linking value when you begin to enter
child records.
 
Reverse your setup. The Address table should be the Main form and the
Subform should be the members table. The reason for this is that your
address is the one side and the members are the many side;
 
Ken & G Vaught already gave you the solutions but I wonder
whether you have the relationship correctly set up. With
Person and Address, there are 3 possible relationships,
each one is correct according to the requirements of the
database. The 3 possibilities are:

* One (Address) to Many (Persons), e.g. some of your
Members are co-habitating and you want to capture this
fact.

* One (Person) to Many (Addresses), a Person can have more
than 1 address, e.g. residence address, work address,
postal address.

* Many (Persons) to Many (Addresses) combined both above.

Your current set-up is for One Address to Many Person. Is
this what you need in your database?

HTH
Van T. Dinh
MVP (Access)
 
Thanks for the valued information.

I can now see the error of my ways. It is a combination of the one to
many relationship, and the main form should be the Address, with the
family members as the sub forum.



Andrew
 
Back
Top