Can't see why I am getting a Error 3464: Data type mismatch in critical expression on the following code;
Private Sub Quantity_AfterUpdate()
Dim intStockCurrent As Integer
Dim intStockSold As Integer
Dim intStockNew As Integer
intStockCurrent = Nz(DLookup("[StockOnHand]", "tblStock", "[SerialNo] = '" & Me!SerialNo & "'"), "0")
intStockSold = Me!Quantity
'check value
MsgBox intStockCurrent, , "CurrentStock"
'check value
MsgBox intStockSold, , "StockSold"
intStockNew = intStockCurrent - intStockSold
'check value
MsgBox intStockNew, , "New Stock Level"
strSQL = "Update tblStock SET StockOnHand = " & intStockNew & " WHERE tblStock.SerialNo = " & Me!SerialNo & ";"
'check sql string
MsgBox (strSQL)
DoCmd.RunSQL (strSQL)
End Sub
I am trying to update the value of a field StockOnHand from the tblStock. This field has a data type of integer. Where I am going wrong??
thanks in advance,
josie
Private Sub Quantity_AfterUpdate()
Dim intStockCurrent As Integer
Dim intStockSold As Integer
Dim intStockNew As Integer
intStockCurrent = Nz(DLookup("[StockOnHand]", "tblStock", "[SerialNo] = '" & Me!SerialNo & "'"), "0")
intStockSold = Me!Quantity
'check value
MsgBox intStockCurrent, , "CurrentStock"
'check value
MsgBox intStockSold, , "StockSold"
intStockNew = intStockCurrent - intStockSold
'check value
MsgBox intStockNew, , "New Stock Level"
strSQL = "Update tblStock SET StockOnHand = " & intStockNew & " WHERE tblStock.SerialNo = " & Me!SerialNo & ";"
'check sql string
MsgBox (strSQL)
DoCmd.RunSQL (strSQL)
End Sub
I am trying to update the value of a field StockOnHand from the tblStock. This field has a data type of integer. Where I am going wrong??
thanks in advance,
josie