-
Auot caculate
Good evening I have a database I have built and has the following boxes or information if you will in it; Units in Stock, Minimum Inv, Required Inventory and Order Qty.
What I want to happen is I have place in "Required Inventory" a value for qty of items I wish to have a base stock. In "Units in Stock" this is the actual qty that is currently in stock. I want "Order Qty" to reconize when "Units in Stock" is less than or equal to " Minimum Inv" then display the difference between "Units in Stock" and "Required Inventory".
I can generate the code for the last part but I cannot get it to do it only when the value in "Units in Stock" drop below the value of "Minimum Inv".
After this I wan it to generate and email alert but was only dealing with one problem at a time.
Thank you the help.
-
-
Good morning here is the code keep in mind I have never tried to do the first part of the code before. I can generate code to performe caculations but this step is a new one for me.
Private Sub Order_Qty_KeyPress(KeyAscii As Integer)
Me.Units_In_Stock acLessThanOrEqual Me.Minimum_Inv, Me.Order_Qty = Me.Required_Qty - Me.Units_In_Stock
End Sub
-
If me.units_in_stock < me.minimum_inv or me.units_in_stock = me.minimum_qty then
me.order_qty=me.required_qty - me.units_in_stock
end if
-
For some reason it does not like the first part of the code. It gives the Error message Complie error "Method or datat member not found" and it is highlighting the following
If Me.Units_In_Stock > Me.Minimum_Inv_ Or Me.Units_In_Stock = Me.Minimum_Inv Then Me.Order_Qty = Me.Required_Qty - Me.Units_In_Stock
I am not for sure why it flags this as a problem as it is an active part of the database?
-
Is the name of the text box on the form the same name as is on the table and the same as in the code? Also I have seen dots being used but never use them myself. I always use a ! - as in Me!Units_In_Stock. Could that be the problem?
-
I did find one thing I had missed and that was at the end of Me.Minimum Inv I should have been using Me.Mimimum Inv. instead. Now the code reads as follows "Expected: Then or GoTo" and errors on the highlighted
If Me.Units_In_Stock > Me.Minimum_Inv. Or Me.Units_In_Stock = Me.Minimum_Inv. Then Me.Order_Qty = Me.Required_Qty - Me.Units_In_Stock
-
Why is there a period after Minimum_Inv? Is that part of the name on the table? Either remove it (best) or enclose the field name in square brackets []. Access likes square brackets around field names but it is ok to leave them out when there are no spaces and no funny characters. This might be a time when they are required.
-
Well that was the problem. I added the period to the table name not even think about in the code it would repesent end of statemen. Once I corrected the table name then changed the name in the code it works just fine. Thank you very much. No I need to tie my alert to my email but that will be my next post.
Thank you very much I love this forum.
Lloyd
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules