Hi everyone
Is there any way to compare tables and automatically update values. I
import a list of products with associated cost prices and selling prices
from an external database into a table called Products which is then linked
to other tables as required. The problem is that the external database
changes on a regular basis. If a product is added today, I can then import
the new database into a temporary table called ProductsWork and compare it
with Products. Any records that are in ProductsWork that aren't yet in
Products will then be added to Products. This is done using the following
query:
INSERT INTO Products ( StockCode, Description, MajDeptID, CostPrice,
SellingPrice )
SELECT ProductsWorkTable.StockCode AS Expr1, ProductsWorkTable.Description
AS Expr2, ProductsWorkTable.MajDeptID AS Expr3, ProductsWorkTable.CostPrice
AS Expr4, ProductsWorkTable.SellingPrice AS Expr5
FROM ProductsWorkTable
WHERE ((([ProductsWorkTable].[StockCode]) Not In (SELECT StockCode from
Products)));
The problem that I'm having is when products are deleted from the main
database. The above query only adds records that weren't found in Products
but which were found in ProductsWork. It doesn't delete records that are in
Products but NOT in ProductsWork. Also, if one of the non-primary key
fields changes (for instance the cost price of one of the products changes)
is there any way for it to update the cost price in Products.
Basically, I'd like to synchronise the two tables in every way, whether it
means adding records, deleting records, making fields identical, whatever.
Any help will be much appreciated.
Thank you in advance,
Michael Thomas
Stock Controller
The Cock 'n Bull cc
Cape Town
South Africa