I am preparing a Business Management System, in which the user enters the details of purchase and sale, where item number identifies the stock availability. Suppose i purchased item1 as Business Stock, it was not in the stock, it is updated in table 4. But if it exists, i gave an SQL query, with Update Command.
Quantity= qty is updating, but Quantity = Quantity + qty is not working.
con.Execute ("update table4 set Quantity = Quantity + qty where Item_code='" & Text3.Text & "'")
While executing this command, the sustem shows the error specified in the title. The code is given Below, if anyone thinks that it can be solved, kindly revert me at [email snipped]
Dim con As New ADODB.Connection
Dim res As New ADODB.Recordset
Dim res1 As New ADODB.Recordset
Dim sql As String
Dim sql2 As String
Dim sql1 As String
Dim qty As String
Dim sql3 As String
Private Sub Command1_Click()
Text7.Text = Val(Text5.Text) * Val(Text6.Text)
sql = ""
sql = sql + "insert into table2 values('" & Text2.Text & "','" & Text1.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "')"
res.Open "select * from table2 where reciept='" & Text2.Text & "'", con, adOpenDynamic, adLockOptimistic
If res.EOF = False Then
MsgBox "Bill no. already Exists", vbCritical, "Verification"
Text2.Text = ""
res.Close
Else
con.Execute sql
MsgBox "Bill Submitted"
res.Close
End If
sql1 = ""
sql1 = sql1 + "insert into table4 values('" & Text3.Text & "','" & Text5.Text & "')"
res1.Open "select * from table4 where item_code='" & Text3.Text & "'", con, adOpenDynamic, adLockOptimistic
If res1.EOF = False Then
MsgBox "Item Already Exists in Stock", vbCritical, "Verification"
res1.Close
qty = Text5.Text
con.Execute ("update table4 set Quantity = Quantity + qty where Item_code='" & Text3.Text & "'")
Else
con.Execute sql1
res1.Close
End If
End Sub
Private Sub Command2_Click()
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
End Sub
Private Sub Form_Load()
Text1.Text = Date
End Sub
Private Sub Form_Activate()
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database21.mdb;Persist Security Info=False"
con.Open
End Sub
Attachments also there, please help if you can, i want the project complete by tomorrow. :sweat: