Insert data in two related tables

Denzel

New member
Local time
Yesterday, 21:23
Joined
Dec 12, 2004
Messages
7
Hi!,
I want to insert a huge number of data (Customer and their adress) into 2 existing related tables in Access. Each table in access is related by some kind of ID (Autonumber-Primary key). The first table is CUSTOMER , the other one is CUSTOMER_ADRESS . Access relate each Customer to his Adress, so if I import data into one table and then import data into another table how would the database know that all the data pertains to the same person. How to insert the new list of customer and adress in yhe appropriate place without using a form?
Thanks for your help.
 
Rich said:
Why do you have separate tables for customer and address?
It's not me who created the database. Actually i don't know why. But i have to insert data into these two related tables.
 
I am assuming that your data is on a flat file format, like Excel, where you have three fields, CustomerID, Customer Name, Customer Address?


Export this table into Access, using the append query, ask the clip how to append query, append the CustomerID, NAme to the first table.

Then the Customer ID, Address to the Address table.

The problem you might encounter is if the CustomerID already exists in the two tables, then you will have an error if the Customer ID is set to "No duplicates" which is always the case for Primary keys.

If the two tables are empty, you wont have a problem. If however the Customer ID is an Autonumber in the provided tables, do not use that Field
but create another one so that it can take your data's customer ID.

The Autonumber should only be use to identify the record ID. It should not be a meaningful data to your whole relational database.
 
Thanks guys for your help.

I added my data by synchronizing the AutoNumber in the target tables. But i have a problem. I want that a customer_adress can be an adress for many customers. How to allow that?
For example possibilty of this Adress: 23, Meloncolly Street to be the adress of the customer: Bill Jackson and Shirley Banks.
Thanks
 

Users who are viewing this thread

Back
Top Bottom