Santi,
Before you try this, backup your database.
When faced with this situation, I generally import the data from the Excel
file into a temporary table.
I then write an update query to update the data in your master table from
the temp table, for those items that are in both, something like:
UPDATE tbl_Master
INNER JOIN tbl_Excel
ON tbl_Master.[Item Number] = tbl_Excel.[Item Number]
SET tbl_Master.[Description] = tbl_Excel.[Description],
tbl_Master.[Unit Price] = tbl_Excel.[Unit Price],
tbl_Master.[Discount] = tbl_Excel.[Discount]
You can then write an append query that will append any new records from
tbl_Excel into tbl_Master.
INSERT INTO tbl_master ([Item Number], [Description], [Unit Price],
[Discount])
SELECT [Item Number], [Description], [Unit Price], [Discount]
FROM tbl_Excel
LEFT JOIN tbl_Master
ON tbl_Excel.[Item Number] = tbl_Master.[Item Number]
WHERE tbl_Master.[Item Number] IS NULL
An alternative method is to create what some people call an UPSERT query,
which is basically an update query which uses a right join rather than an
inner join. Because of the right join the result is that Access will update
those records that already exist, and insert those that don't, all in one
step.
It would look like:
UPDATE tbl_Master
RIGHT JOIN tbl_Excel
ON tbl_Master.[Item Number] = tbl_Excel.[Item Number]
SET tbl_Master.[Description] = tbl_Excel.[Description],
tbl_Master.[Unit Price] = tbl_Excel.[Unit Price],
tbl_Master.[Discount] = tbl_Excel.[Discount]
----
HTH
Dale
Santi said:
I want a master table to have the most up to date information which is based
on an excel file that I get on a monthly basis that has existing items which
has to be updated and, new ones which are not part of the master table but
that I want to include. What structure, queries or tables do I need to make
this happen? Any guidance is greatly appreciated.
*I want to be able to update and include new information if needed on the
following common fields: Item number, Description, Unit price and discount