Oops, BIG Mistake. (it's been a while) Forget the previous message!
This is it:
Make a new tabel called PriceHistory with the following fields:
ProductKey Numeric :Foreignkey of the related product
StartDate Date/Time
ate that the price was raised(or
lowered) to the price in this record
Price Currency :The price
Make the first two columns the primairy key. (don't forget or this will be a
slow query.) If you also make a relationship between the ProductKey in this
table and the Key column in the products table you get to use the nifty
subdatasheet feature so it's easier to use this all.
In this table, you keep a log of all the prices that ever were for this
product with their startingdate. For the current price of an item use the
following query:
SELECT
Products.Name,
PriceHistory.Price AS Price
FROM
Products INNER JOIN PriceHistory ON
Products.Key = PriceHistory.ProductKey
WHERE
PriceHistory.StartDate=(SELECT MAX(StartDate) FROM PriceHistory WHERE
PriceHistory.ProductKey = Products.Key AND StartDate<=Date());
When you want to find the price for an order, inner join products,
pricehistory, orders and orderlines (i presume it's like this) and the
instead of the "date()" function at the end type "Orders.Date" So you take
the price for the day the order was placed instead of today. Hope this
helps.
GJ