how to put a validation on a calculated field

ashni

Registered User.
Local time
Yesterday, 19:48
Joined
Jan 10, 2010
Messages
14
hey,
i am making a stock control system. in the system i have an order form in which i would like the order not to process if stock is below a certain level.
the fields im using to calculate the new stock level is stock level and quantity ordered.
i want a message to come up when the user clicks process order if the new stock level is below 10.
please help
thank you
 
hey,
i am making a stock control system. in the system i have an order form in which i would like the order not to process if stock is below a certain level.
the fields im using to calculate the new stock level is stock level and quantity ordered.
i want a message to come up when the user clicks process order if the new stock level is below 10.
please help
thank you

Unfortunately you are asking about how to do something specific with your custom database that we know nothing about.

Unless you will give us a lot more details about your database.

If it were me, I would use VBA code in the Form's Before update to check each item as it is entered.
 
It is normal to enter orders even if stock is not available and then during the order progression process orders are processed in a predefined order and stock is reduced until stock is zero.

Orders unfulfilled either in part or whole for any stock item are put on back order and these orders help establish what stock needs to be sourced.
Information stored in the system can help you produce a system that will mean that stock can be sourced on a just in time basis.

I used to work on stock control systems for a software house.
 
It is normal to enter orders even if stock is not available and then during the order progression process orders are processed in a predefined order and stock is reduced until stock is zero.

Orders unfulfilled either in part or whole for any stock item are put on back order and these orders help establish what stock needs to be sourced.
Information stored in the system can help you produce a system that will mean that stock can be sourced on a just in time basis.

I used to work on stock control systems for a software house.

That works great if that is how your business model works. That is definitely not the only way to handle inventory. I have been doing custom inventory control systems for over 30 years. What you described works good for purchasing from a large whole sellers.

I have many clients that can NOT backorder some items because the items are produced in limited quantities. Another example would be a "liquidator".
 
Another tip is to have a flag for each stock item that indicates whether the stock item can have a zero or negative balance. This way you can pick from a never ending supply. The fact that your db says there are none in stock does not always tell the truth. There is usually a delay between goods arriving and being updated on the PC.

Also you need to be looking at
Economic Order Qty, Min Order Qty, Max Order Qty,delviery days, etc.
 
OK, let's be precise. Your question is slightly ambiguous to me, and I freely admit it might be my understanding that is the fault so don't take that as a bad comment on you.

On a table, you can put a validation if you wanted, but you should never be storing calculated fields for inventory things. It is far too easy to desynchronize your on-hand quantity from reality. Search this forum for a huge number of threads on exactly this subject, "Store calculated field"

On a query, there is no place to put a validation, but a query is the right way to handle stock levels for most cases. With a good summation query across all transactions, you can have a highly accurate answer to on-hand levels.

The solution to your validation problem is that you put this test on the FORM, which is capable of looking at something if you place orders via a button-click. Let's say you make a list of things you'd like to place on the order invoice. So you build a sub-form and child table to hold invoice line items. You write some VBA in the OnClick routine of the button that says, "Place an order." Then the VBA does your validation by stepping through the selections in that invoice to compare against on-hand quantities. If you need to pop up the message box, the OnClick code is the prime place to do it.

For the sake of discussion, I'll describe how I would do this. Let's say I have a stock number I'll call SKU. My convention is that if I have stock on hand, my numbers will be positive and if I'm back-ordered, my numbers will be negative. I will have various transaction types. To take a fairly general case, let's say I have

  • Stock Add - a shipment came in and has been placed into inventory
  • Stock Pull - an order came in and stock was removed to fill an order
  • Stock Bad - an attempt to pull stock found a defective item that cannot be retained in the on-hand count
  • Stock Return - a pulled order was canceled and stock was returned
  • Stock Adjust Up - after an inventory, more of this SKU was found than we thought we had
  • Stock Adjust Down - after an inventory, less of this SKU was found than we thought we had
  • Stock Archive Point - see discussion later

In one or more transaction tables, you have SKU, quantity, effective quantity, transaction type, transaction date, and perhaps a code number that identifies something about the transaction to which this is related - invoice number, shipment number, inventory special transaction number, etc. The effective quantity is merely the quantity of the transaction times either +1 if it puts things in stock or -1 if it takes things out of stock.

The amount of stock on hand is therefore (loosely stated):

SELECT SUM([EffectiveQty]) AS STOCKLEVEL from TRANSACTIONS GROUP BY [SKU];

So you look up the STOCKLEVEL for a given SKU. And that is the current level of stock for the SKU. Since you have dates in the transactions, you can also do historical studies by performing the same query but with a WHERE clause on the date field for summing transactions before a given date.

The transaction type for archive point is because you have this humongous table of transactions and you sometimes want to archive some of the oldest transactions. So you do the stock-level query for transactions up to the last date you want to archive. Replace ALL of the older transactions for the SKU with a single Archive-point transaction that shows the correct STOCKLEVEL for that SKU on that date. (Might have to do it in multiple steps.)

Anyway, the idea here is if you have something like this, you can simply do a DLookup of the value of the summation query, or you can do a direct DSum of the transaction tables. Your button-click code thus has an easy test to decide that SKU 123456987 can or cannot be pulled from stock.

If you cannot keep all transactions in the same table (and I understand that can happen), look at UNION queries as a way to "synthesize" a transaction table from selected fields (even possibly with different names) in many different contributing tables. Then take your sums from the UNION query. Access Help talks about UNION queries. They can be quite helpful in this case if you don't want to totally rewrite your tables.
 

Users who are viewing this thread

Back
Top Bottom