Appending headeaches
How can i append only new orders?
I order to gather every day sales information from an office i have made 2 append queries. All works fine for the first time, but after that each time i append, i receive the sum doubled, and so on. In order to get some help i will have to make myslef more clear.I calcluate on 2 fields: sum and extended price. So for example if the first time i receive sales 30 tons, next time the query shows 60 tons which is not true. Obviously i will have to append only new orders, but how the query should know which orders are new and how can i forbid for entering information second time? The table Orders1 and Order details1 are being sent to me from another town and i will have to append it to the query orders and order details.
The field OrderId in the tabble order has a unique value and is an a Autonumber, whule the field OrderId in the table order details is a Number. In this way the two tables are connected in one to many relationship. In order to show my query to the Forum, i have converted them in an SQL form
1. query AppendOrders in SQL form :
INSERT INTO orders ( OrderID, CustomerID, OrderDate, paymentid, invoicedate )
SELECT orders1.orderid AS Expr1, orders1.customerid AS Expr2, orders1.orderdate AS Expr3, orders1.paymentid AS Expr4,
orders1.invoicedate AS Expr7
FROM orders1;
2. query Append Order details
INSERT INTO [order details] ( OrderID, ProductID, UnitPrice, Quantity, Discount, liters, extendedprice, pieces, cartons )
SELECT [order details1].OrderID, [order details1].ProductID, [order details1].UnitPrice, [order details1].Quantity, [order
details1].Discount, [order details1].liters, [order details1].extendedprice, [order details1].pieces, [order details1].cartons
FROM [order details1];
My question is how can i append only the orders which have not been appended?