greensleeves149
Member
- Local time
- Today, 21:25
- Joined
- Feb 27, 2022
- Messages
- 49
Hi all,
I have a form with two subforms on it. Both subforms have a "total" summation in the footer section of each form. On the second form, when a user updates the quantity for a line item, I currently have some code on the 'AfterUpdate' property of the 'Quantity' control, which should check to see that the user doesn't over-allocate stock that doesn't exist.
For example, if subform A is showing that 10 Widgets are available, subform B allows the user to distribute those 10 Widgets to many different distribution centers. So let's say 4 was allocated to distribution center 1, then you have the balance of 6 to allocated to other distribution centers. The code is just there to stop someone from accidently allocating say 8 to distribution center 2, after allocated 4 to distribution center 1 (therefore 12 required in this example) when only 10 are available.
I have a 'Total Quantity Allocated' in the footer section of Subform B. This is adding up the line item Quantities. "MaxPackagesAvail" is from subform A. Here's the code under the AfterUpdate Property of "Quantities":
When happens when running this, if the user allocates stock to different distribution centers, the "AllocatedTotal" isn't recalculating immediately and therefore the IF statement and Messagebox won't fire- allows users to allocated any amount to the distribution centers.
Am I using the wrong Form Property to update the AllocatedTotal field immediately so the code captures overallocated stock or have I done something else wrong?
Thank you for your help.
I have a form with two subforms on it. Both subforms have a "total" summation in the footer section of each form. On the second form, when a user updates the quantity for a line item, I currently have some code on the 'AfterUpdate' property of the 'Quantity' control, which should check to see that the user doesn't over-allocate stock that doesn't exist.
For example, if subform A is showing that 10 Widgets are available, subform B allows the user to distribute those 10 Widgets to many different distribution centers. So let's say 4 was allocated to distribution center 1, then you have the balance of 6 to allocated to other distribution centers. The code is just there to stop someone from accidently allocating say 8 to distribution center 2, after allocated 4 to distribution center 1 (therefore 12 required in this example) when only 10 are available.
I have a 'Total Quantity Allocated' in the footer section of Subform B. This is adding up the line item Quantities. "MaxPackagesAvail" is from subform A. Here's the code under the AfterUpdate Property of "Quantities":
Code:
Private Sub Quantity_AfterUpdate(Cancel As Integer)
Dim MaxPackage As Integer
MaxPackage = Forms!frmCenterOrders!frmNetPurchasedInventory.Form!MaxPackagesAvail
If Me.AllocatedTotal > MaxPackage Then
MsgBox "You cannot allocate more items than what is available"
Me.Quantity = Null
End If
End Sub
When happens when running this, if the user allocates stock to different distribution centers, the "AllocatedTotal" isn't recalculating immediately and therefore the IF statement and Messagebox won't fire- allows users to allocated any amount to the distribution centers.
Am I using the wrong Form Property to update the AllocatedTotal field immediately so the code captures overallocated stock or have I done something else wrong?
Thank you for your help.