I have an error when I enter a order for items that are in stock but I get an error " Item Not Found in this Collection (3265) Quantity_AfterUpdate. Thanks for any Help.
I have an error when I enter a order for items that are in stock but I get an error " Item Not Found in this Collection (3265) Quantity_AfterUpdate. Thanks for any Help.
It would help to see your actual code and the line that errors. The error implies that you're referring to an object or method that doesn't exist.
I think this is what you're asking for, If not please let me know.
Private Sub Quantity_AfterUpdate()
On Error GoTo ErrorHandler
Dim IT As InventoryTransaction
Dim PurchaseOrderID As Long
Dim SupplierID As Long
IT.ProductID = Nz(Me![Product ID], 0)
IT.Quantity = Me![Quantity]
IT.AllOrNothing = True
IT.InventoryID = Nz(Me![Inventory ID], NewInventoryID)
'Request Hold on specified Inventory
If Inventory.RequestHold(Me![Order ID], IT) Then
Me![Inventory ID] = IT.InventoryID
Me![Status ID] = OnHold_OrderItemStatus
'Insufficient Inventory
ElseIf Me![Status ID] <> None_OrderItemStatus And Me![Status ID] <> NoStock_OrderItemStatus Then
MsgBoxOKOnly InsufficientInventory
Me![Quantity] = Me.Quantity.OldValue
'Attempt to create purchase order for back ordered items
ElseIf MsgBoxYesNo(NoInventoryCreatePO) Then
SupplierID = Inventory.FindProductSupplier(IT.ProductID)
'Create purchase order if we have supplier for this product
If SupplierID > 0 Then
If PurchaseOrders.Generate(SupplierID, IT.ProductID, Me![Quantity], Me![Order ID], PurchaseOrderID) Then
PurchaseOrders.OpenOrder PurchaseOrderID
Me![Status ID] = OnOrder_OrderItemStatus
Me![Purchase Order ID] = PurchaseOrderID
eh.TryToSaveRecord
Else
Me![Status ID] = NoStock_OrderItemStatus
End If
'Could not find a supplier for this product
Else
MsgBoxOKOnly CannotCreatePO_NoSupplier
Me![Status ID] = NoStock_OrderItemStatus
End If
Else
Me![Status ID] = NoStock_OrderItemStatus
End If
Done:
Exit Sub
ErrorHandler:
' Resume statement will be hit when debugging
If eh.LogError("Quantity_AfterUpdate") Then Resume
End Sub
another thing that might have happened is that you dimmed a variable incorrectly. e.g. - you used this code:Code:dim cbo as combobox set cbo = me.textbox
Temporarily comment out this line:
On Error GoTo ErrorHandler
and run the code. When it errors you will be allowed to go into debug mode and see exactly what line is throwing the error.
where would I insert that line at ?
This is what comes up on VB "Debug.Assert False ' Stop code so that you can debug"
You wouldn't insert it, it's already there. If you delete it or comment it out, the code will go to the offending line when it errors. With that line in there, code just runs to the error trap and you're not sure what line is causing it.
That worked thank you for your help .
Happy to help.