I
Ian Baker
I have a db that amongst other things handles stock control on items that
are sold. Currently I hard store the current stock level with each sale
transaction reducing the stock level and each stock received transaction
increasing the stock level. I know this is the wrong way but it's the
fastest way and although it's the fastest way it is prone to a risk of
innacuracy. So to do it the right way and base these values on queries
(calculations rather than hard store) I need to know whether the following
is the best way to achieve the values:
1. Quantity currently on order
2. Quantity currently in stock
I have 4 tables (each one having a quantity field etc):
1. tblPurchaseOrder (records of stock that have been ordered)
2. tblStockReceived (records of stock that have been receive)
3. tblSalesOrder (records of stock that have been sold)
4. tblStockAdjustment (for manual adjustments + or - i.e. breakages etc)
I will need to:
Create a query for each table with each one summing the quantities of each
item
1. qrysumPurchaseOrder
2. qrysumStockReceived
3. qrysumSalesOrder
4. qrysumStockAdjustment
To get the "Quantity currently on order" I would create another query which
contains the summed quantity fields of qrysumPurchaseOrder and
qrysumStockReceived and a calculated field of::
TotalOnOrder = sumPurchaseOrderQty - sumStockReceivedQty
To get the "Quantity currently in stock" I would create another query which
contains the summed quantity fields of qrysumStockReceived,
qrysumStockAdjustment and qrysumSalesOrder and a calculated field of:
TotalInStock = sumStockReceivedQty + sumStockAdjustmentQty -
sumSalesOrderQty
Then for each form I would have to use either or both nested queries
depending on which values I need with the forms normal recordsource.
Is this the best way as I feel it will get rather slow as the db grows?
Thanks
are sold. Currently I hard store the current stock level with each sale
transaction reducing the stock level and each stock received transaction
increasing the stock level. I know this is the wrong way but it's the
fastest way and although it's the fastest way it is prone to a risk of
innacuracy. So to do it the right way and base these values on queries
(calculations rather than hard store) I need to know whether the following
is the best way to achieve the values:
1. Quantity currently on order
2. Quantity currently in stock
I have 4 tables (each one having a quantity field etc):
1. tblPurchaseOrder (records of stock that have been ordered)
2. tblStockReceived (records of stock that have been receive)
3. tblSalesOrder (records of stock that have been sold)
4. tblStockAdjustment (for manual adjustments + or - i.e. breakages etc)
I will need to:
Create a query for each table with each one summing the quantities of each
item
1. qrysumPurchaseOrder
2. qrysumStockReceived
3. qrysumSalesOrder
4. qrysumStockAdjustment
To get the "Quantity currently on order" I would create another query which
contains the summed quantity fields of qrysumPurchaseOrder and
qrysumStockReceived and a calculated field of::
TotalOnOrder = sumPurchaseOrderQty - sumStockReceivedQty
To get the "Quantity currently in stock" I would create another query which
contains the summed quantity fields of qrysumStockReceived,
qrysumStockAdjustment and qrysumSalesOrder and a calculated field of:
TotalInStock = sumStockReceivedQty + sumStockAdjustmentQty -
sumSalesOrderQty
Then for each form I would have to use either or both nested queries
depending on which values I need with the forms normal recordsource.
Is this the best way as I feel it will get rather slow as the db grows?
Thanks