Run-Time Error 3075
Karim Vazirinejad
186
Reputation points
I have a program that control the inventory quantity in stocks. When the operator assign an inventory quantity to an order, the software should lock the quantity and doesn't allow other operators to assign the quantity.
I wrote a code and control it several times but I don't know why it show the error. My code is:
The error is in this line:
curStockAssigned = Nz(DLookup("AssignedQty", "qryAssignedInventoryBalance", strWhere2), -1)
Private Sub Form_BeforeUpdate(Cancel As Integer)
'I want to check the inventory that we can assign to a order
'I use StockInHand and calculate the inventory balance that we can assign
If Not IsNull(Me.cboInventoryID) Then
Const message = "There is not enough inventory for assignment"
Dim curStockInHand As Currency
Dim curStockAssignable As Currency
Dim curStockAssigned As Currency
Dim strWhere As String
Dim strWhere2 As String
'Find the criteria for comparing balance![54337-error.jpg][1]
strWhere = "True"
If Not IsNull(Me.Parent.StockID) Then
strWhere = strWhere & " AND tblInventoryTransaction.StockID= " & Me.Parent.StockID
strWhere2 = strWhere2 & " AND tblInventoryPermission.StockID= " & Me.Parent.StockID
strWhere2 = strWhere2 & " AND tblInventoryPermission.Assigned= 0 "
End If
If Not IsNull(Me.cboInventoryID) Then
strWhere = strWhere & " AND tblInventory.InventoryID= " & Me.cboInventoryID
strWhere2 = strWhere2 & " AND tblInventory.InventoryID= " & Me.cboInventoryID
End If
'find the quantity in stock from query
curStockInHand = Nz(DLookup("[Balance]", "qryInventoryBalanceControl", strWhere), -1)
'Now find the quantity that we can assign, it is the diffrence between StockInHand and Stock Assignedin Permissions
curStockAssigned = Nz(DLookup("AssignedQty", "qryAssignedInventoryBalance", strWhere2), -1)
If curStockInHand And curStockAssigned <> -1 Then
curStockAssignable = curStockInHand - curStockAssigned
If Me.AssignedQty > curStockAssigned Then
MsgBox message, vbExclamation + vbMsgBoxRight + vbMsgBoxRtlReading, "Not Enough Inventory"
Cancel = True
End If
Else
MsgBox "This type of inventory is not in the customer stock", vbExclamation + vbMsgBoxRight + vbMsgBoxRtlReading, "Discrepancy"
Cancel = True
End If
End If
End Sub
Sign in to answer