Results 1 to 9 of 9
  1. #1
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36

    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.

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Show us the coding

  3. #3
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    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

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    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

  5. #5
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    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?

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    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?

  7. #7
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    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

  8. #8
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    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.

  9. #9
    rovman is offline Advanced Beginner
    Windows XP Access 2002
    Join Date
    Sep 2011
    Posts
    36
    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

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums