I WAS CREATING AN INVENTORY SYSTEM USING VB 6 AND ADODC. HERE IS MY CODE
Private Sub Command1_Click()
Dim temp2 As Integer
Dim temp As Integer
If Text1.Text = 0 Then error.Show Else If Text1.Text > 0 Then purchase.Show
Form38.Hide
Set rs = New ADODB.Recordset
rs.Open "select *from purchasetable", cn, adOpenKeyset, adLockOptimistic
temp = 100
temp2 = Val(rs!Remaining)
rs.AddNew
rs!Name = Label6.Caption
rs!Quantity = Text1.Text
rs!Total = Label5.Caption
rs!MAXstock = 100
rs!Remaining = temp - Val(Text1.Text)
rs.Update
End Sub
Private Sub Command2_Click()
Form1.Show
End Sub
Private Sub Text1_Change()
Label5.Caption = Val(Text1.Text) * Val(Label4.Caption)
End Sub
PURCHASETABLE
ID - PRODUCT ID
ITEM - THE ITEM TO BE PURCHASED
QUANTITY - THE QUANTITY OF ITEM TO BE PURCHASED
MAXSTOCK - THE MAXIMUM STOCK OF ITEMS
REMAINING - THE REMAINING STOCK AFTER EACH PURCHASED
ISSUE: AN ATTACHED SCREENSHOT OF THE DATABASE TABLE ASSOCIATED WITH THIS CODE. THE PROBLEM IS EVERY TIME A PURCHASE IS MADE, AN ITEM REGARDLESS OF ANY QUANTITY THE REMAINING ON THE TABLE WOULD ALWAYS BE DEDUCTED TO MAXSTOCK ROW OF 100. WHEN THE REMAINING SHOULD BE DEDUCTED FROM THE THE QUANTITY(THAT IS QUANTITY OF ITEMS PURCHASED). COULD HELP ME OUT WITH MY CODE OR COULD YOU HELP ME REWRITE THEM TO WORK