all i want is if the value of my product stock is 0 then the message box show for example theres no more product stock and also i want is if the user inputted higher value in my text2.text for example my product stock left is 5 if he/she inputted 6 the message box show theres no more product stock
this is my code
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\Desktop\Inventory System\PharmacyInventory.mdb;Jet OLEDB:System Database=system.mdw;", "admin", ""
Set rs = New ADODB.Recordset
rs.Open "Select * from Product", cn, adOpenKeyset, adLockPessimistic
If Text2.Text = "" Then
Text2.SetFocus
MsgBox "Please Input the Quantity Fields", vbCritical, "Product Return"
End If
If Val(rs!pstock) < 0 Then
MsgBox "There's no More to Return", vbCritical
Exit Sub
ElseIf IsNull(rs!pstock) = True Then
MsgBox "There's no More to Return", vbCritical
Else
rs.Fields![pstock] = Val(rs.Fields![pstock]) - Val(Text2.Text)
rs.Update
cn.Execute "INSERT INTO ProductReturn (drno, pcode, scode, quantity, unit, pdescription, [date]) VALUES ('" + Combo1.Text + "','" + Label8.Caption + "','" + Label9.Caption + "','" + Text2.Text + "','" + Label11.Caption + "','" + Text4.Text + "',#" + Label10.Caption + "#)"
Combo1.Text = ""
Label8.Caption = ""
Text2.Text = ""
Label11.Caption = ""
Text4.Text = ""
Label9.Caption = ""
Label10.Caption = ""
MsgBox "Return Successful", vbInformation
Call grd_Data_Loader
End If