0
OpenConn()
     Dim li As Integer
     Dim qqttyy As Integer = Val(ListView1.Items(li.Index).SubItems(3).Text)
     Dim codee As String = ListView1.Items(li.Index).SubItems(1).Text
     OleDa.UpdateCommand.CommandText = "UPDATE Inventry SET QTY = QTY -'" & qqttyy & "'WHERE CODE ='" & codee & "'"
     OleDa.UpdateCommand.ExecuteNonQuery()
CloseConn()
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by G_Waddell
0

Hi
I'm not 100% sure Access would support this but your query syntax is wrong anyway.
I assume field QTY is a numeric type i.e. not a string.

In your query you have encapsulated the qqttyy value in Single quotes i.e. your query says it is a string:

UPDATE Inventry SET QTY = QTY - ' " &qqtty &" ' WHERE CODE ='" &codee &"'"

i.e. say qqtty is 6 if the above was typed directly into access this is what you get:
UPDATE Inventry SET QTY = QTY -'6' WHERE Code='MyCode'

In otherwords, if QTY is a number you are trying to take the String value "6" from it.

Try dropping those single quotes so you will have:
UPDATE Inventry SET QTY = QTY - 6 WHERE Code='MyCode'

Not 100% sure it will work but at least you'll be subtracting numbers from numbers.

Edited by G_Waddell

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.