How do I add data in a table and have it relate to another.

K

KB

I have set up 4 tables. The first relates to client details(names and
addresses). The other 3 relate to products and courses. When I enter the
personal details table with an auto key, how do I then enter details in the
other tables and have it relate to the person on my client details
 
B

Baz

I assume that the tables you wish to relate each have a foreign key which
relates to the autonumber primary key on your main table.

The usual thing to do would be to:

- create a form for each of the 4 tables
- on the main table's form, add the three other forms as subforms, linked
on the primary key/foreign key field.

It will help (with lots of things) if you first open the relationships
window and set up the relationships between the tables.
 
J

John W. Vinson

I have set up 4 tables. The first relates to client details(names and
addresses). The other 3 relate to products and courses. When I enter the
personal details table with an auto key, how do I then enter details in the
other tables and have it relate to the person on my client details

That depends on the relationship between the tables. Which of the following
correctly describes the relationships:

Each Person can take zero, one, or many Courses.
Each Course is taken by either zero or one person, never more.

or

Each Person can take zero, one, or many Courses.
Each Course is taken by zero, one, or many People.

Similarly for Products.

I'm guessing that the latter is accurate - a "many to many" relationship. If
so you need *three more tables* to implement the relationship. In the Courses
example, you might have a table named Enrollment, with fields for the PersonID
(a link to the primary key of the Client table) and the CourseID (a link to
the primary key of Courses). If ten people are enrolled in a course you'll add
ten records to this table - using a Subform on the Clients form, probably.

See the tutorials here for more resources:

Jeff Conrad's resources page:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html

The Access Web resources page:
http://www.mvps.org/access/resources/index.html

A free tutorial written by Crystal (MS Access MVP):
http://allenbrowne.com/casu-22.html

MVP Allen Browne's tutorials:
http://allenbrowne.com/links.html#Tutorials

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