how can i delete the record in my Sold To table if the quantity is = 0
heres my code in my command button
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
cn.Execute "INSERT INTO CustomerReturn (cno, pcode, quantity, unit, pdescription, ornumber, [date]) VALUES ('" + Combo1.Text + "','" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "',#" + Text6.Text + "#)"
rs.Open "select * from Product where pcode='" & Text1.Text & "'", cn, adOpenKeyset, adLockPessimistic
If rs.RecordCount > 0 Then
rs.Fields![pstock] = Val(rs.Fields![pstock]) + Val(Text2.Text)
rs.Update
End If
MsgBox "Return Successfully", vbInformation
Set rs1 = New ADODB.Recordset
rs1.Open "Select * from Soldto where cno='" & Combo1.Text & "'", cn, adOpenKeyset, adLockPessimistic
If rs1.RecordCount > 0 Then
rs1.Fields![quantity] = Val(rs1.Fields![quantity]) - Val(Text2.Text)
rs1.Update
Call grd_Data_Loader
End If
If Val(rs1!quantity) = 0 Then
rs1.Delete
rs1.Requery
End If
Combo1.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Call grd_Data_Loader
please help me thanks a lot!