Member Avatar for LeafProduction
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Call Open_database()
        XSQL = "Select stock from item where itemcode like '" & Trim(TextBox2.Text) & "'"
        CMD = New OleDb.OleDbCommand(XSQL, CONN)
        CMD.ExecuteReader()

        If Missing Code Here
            MsgBox("Alert")

        Else
            XSQL = "Update item set Stock = Stock - " & Trim(TextBox1.Text) & " where itemcode like '" & Trim(TextBox2.Text) & "' and stock > 0"
            CMD = New OleDb.OleDbCommand(XSQL, CONN)
            CMD.ExecuteNonQuery()
            CMD.Dispose()
            CONN.Close()
            MsgBox("Alert", MsgBoxStyle.Information)
    End Sub

hello..i might need some help here..i need to make a Condition where if my item is less than 0 then a msgbox will pop up...can any1 help me ? thx.

Member Avatar for LeafProduction

I mean..how do i get the value from the database where itemcode like value of textbox
and label = value(from database that i got)
ty ty

XSQL = "Select stock from item where itemcode ='" & Trim(TextBox2.Text) & "'"
CMD = New OleDb.OleDbCommand(XSQL, CONN)
Dim obj as OleDbDataReader
Dim found as boolean=false

obj=CMD.ExecuteReader()
if obj.Read() Then
   found=true
End if
obj.Close()

If Not Found Then
  MsgBox("Alert")

Else
 XSQL = "Update item set Stock = Stock - " & Trim(TextBox1.Text) & " where itemcode like '" & Trim(TextBox2.Text) & "' and stock > 0"
 CMD = New OleDb.OleDbCommand(XSQL, CONN)
 CMD.ExecuteNonQuery()
 CMD.Dispose()
 CONN.Close()
 MsgBox("Alert", MsgBoxStyle.Information)
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.