So if you have this in your database:
Code:
Customer_ID Customer_Name Customer_Address ----> etc
1 Customer A 111 Wherever Lane
but in your excel file you have
Code:
Customer_ID Customer_Name Customer_Address ---- etc
1 Customer AA 112 Whatsit Road
You are going to replace everything in your existing record with the incoming value?
and if it's a new customer ID you're going to insert that record.
so let's say this is your existing recordset (tblCustomers):
Customer_ID |
Customer_Name |
Customer_Address |
1 |
Customer A |
Address 1A |
2 |
Customer B |
Address 1B |
let's say this is your incoming recordset (tblIncoming):
Incoming_ID |
Incoming_Name |
Incoming_Address |
1 |
Customer AA |
Address 1AA |
2 |
Customer B |
Address 1B |
3 |
Customer C |
Address 1C |
Your request is actually 2 different queries.
1. Update any existing customers with the 'most recent' information
2. Add any new customers to your record set
So the first part would be a query like:
Code:
UPDATE tblCustomers INNER JOIN tblIncoming ON tblCustomers.Customer_ID = tblIncoming.Incoming_ID SET tblCustomers.Customer_Name = [incoming_name], tblCustomers.Customer_Address = [incoming_address];
This will update your tblCustomers with the data in your tblIncoming wherever the customerID's match.
The second query would be:
Code:
INSERT INTO tblCustomers ( Customer_ID, Customer_Name, Customer_Address )
SELECT tblIncoming.Incoming_ID, tblIncoming.Incoming_Name, tblIncoming.Incoming_Address
FROM tblIncoming;
This assumes that you have some method in place to prevent duplicate customer_ID's in the table tblCustomers.