none
Calculate a total quantity on update of fields "number of containers" and "quantity per container" RRS feed

  • Question

  • All,

    I want to update the total quantity of parts on a shipper based upon the number of containers and the quantity per container.  I want this to happen as soon as either calculation parameters have changed.  I tried doing this with "on change", "after update", "dirty".  The change occurs only when I change the part number through a combo box that I setup earlier in the form.

    I would think this would be very easy, but I am not finding it to be.

    This is a shipper form that I am building for an 856 file to be sent to a customer.  If anyone has an example of a shipper form that will help me that would be fantastic.  One slight wrinkle that has caused me the most problems is that the parts loaded onto the shipper are customer specific, so I have to be able to restrict the shipper in that way.

    Please advise.

    Regards,

    David

    Tuesday, July 4, 2017 4:04 PM

Answers

  • Hi SquirrelMan,

    you had mentioned that,"I want to update the total quantity of parts on a shipper based upon the number of containers and the quantity per container." , "The change occurs only when I change the part number through a combo box that I setup earlier in the form."

    so do you mean that if any of the two i.e. 'number of containers' and 'quantity per container' get changes it should update the total quantity and it should not wait for changing the part number combobox.

    can you show us your code.

    it looks like you had wrote the code on combo box event.

    why don't you try to put your code on  'number of containers' and 'quantity per container' event or try to use events of form instead of combobox.

    then whenever you change anything on the form your code will get executed.

    this is a general idea, it is better if you post your code so that we can try to check it to know what we can do to solve the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by SquirrelMan Saturday, January 20, 2018 3:40 PM
    Wednesday, July 5, 2017 1:43 AM
    Moderator

All replies

  • Hi David,

    If you're saying that you're "storing" the total quantity in a field, then it's probably part of your problem. As you found out, storing a calculated value becomes undependable as soon as the other values change. Instead, try not storing the calculated values and just simply calculate them when you need them, like in a query for your form or report.

    Hope it helps...

    Tuesday, July 4, 2017 4:10 PM
  • > I want this to happen as soon as either calculation parameters have changed

    What exactly do you mean? I'm speculating you have a subform (datasheet or continuous forms) with two textboxes NumberOfContainers and QuantityPerContainer, and you want the TotalQuantity to update immediately when an edit is made in any of these fields. Correct?


    -Tom. Microsoft Access MVP

    Tuesday, July 4, 2017 4:13 PM
  • Hi SquirrelMan,

    you had mentioned that,"I want to update the total quantity of parts on a shipper based upon the number of containers and the quantity per container." , "The change occurs only when I change the part number through a combo box that I setup earlier in the form."

    so do you mean that if any of the two i.e. 'number of containers' and 'quantity per container' get changes it should update the total quantity and it should not wait for changing the part number combobox.

    can you show us your code.

    it looks like you had wrote the code on combo box event.

    why don't you try to put your code on  'number of containers' and 'quantity per container' event or try to use events of form instead of combobox.

    then whenever you change anything on the form your code will get executed.

    this is a general idea, it is better if you post your code so that we can try to check it to know what we can do to solve the issue.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by SquirrelMan Saturday, January 20, 2018 3:40 PM
    Wednesday, July 5, 2017 1:43 AM
    Moderator