# Problem : Stock Control in MS ACCESS with FIFO

Problem : Stock Control in MS ACCESS with FIFO

Allready I’ve got some solution in Ms Access 2002 for stock control ( purchasing and sales), but when it comes to calculate the price then i got the problem, because  I want everything to be sold with purchasing price + profit. So I’m not interested on full solution but only sugestions how to calculate the sale price for each product by method (FIFO or LIFO):

Example for goods in stock:
PrID PurchaseDate Quantity Price
001 01/01/2007 50 1
001 01/02/2007 150 2

If we are going to sale the 100 pieces of product 001 on date 02/02/2007 than price should be calculated in this way:

PrID SaleDate Quantity Price Profit Value
001 02/02/2007 50 1 10 60
001 02/02/2007 50 2 10 110
——————————————————–
So my application should take out from stock Product 001 on date 02/02/2007 Quantity 100 (50 from first purchase and rest from second) with cost price of first purchase (50×1) and second purchase (50×2) in thase case 1.5 adding profit 20 and total value of sold goods is 170

#### Stock Control in MS ACCESS with FIFO

I see at least five tables:

Vendors
======
VendorID
VendorName
etc.

Clients
=====
ClientID
ClientName
etc

Products
======
ProdID
ProdName
etc.

Purchases
========
PurID – primary key
ProdID – foreign key from Products
VendorID = long
PurDate – datetime
Qty – long
UnitCost – Currency

Sales
====
SalesID – primary key
ProdID – foreign key from Products
ClientID – foreign key from Clients
SalesDate – datetime
Qty – long
Profit – Currency
PurID – long – once you have decided on the stock depletion method

To determine the stock on hand for a given product:

SELECT Sum(Purchases.Amt)-Sum(Sales.Qty)From Purchases Inner Join Sales On Purchases.ProdID=Sales.ProdID WHERE Purchases.ProdID=[EnterProdID];

When you get down to defining a stock depletion method of FIFO or LIFO, it will now require annotating each Sales record with the source, ie. PurID and in that process, do a test on dates. &nbsp;Anyway, I’m not going to try and design the system, but as you said, provide a few ideas on how to go about this task. &nbsp;Good Luck.