-1

how can i determine that may text1.text is equal to my product code?? heres 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 rs.Fields!pcode = Text1.Text Then
MsgBox "The Product Code is Already Exist!", vbCritical
Exit Sub
Else
Dim s
s = "INSERT INTO Product (pcode, brandname, genericname, price, pstock) VALUES ('" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "','" + Text4.Text + "','" + Text5.Text + "')"
cn.Execute s, adExecuteNoRecords
MsgBox "Product Successfully Added", vbInformation
Call Form_Load
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End If

Votes + Comments
49 posts and you still refuse to use code tags?
2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by ryan311
0
rs.Open "Select PCODE from Product WHERE PCODE = '" & Trim(Text1.Text) & "'", cn, adOpenKeyset, adLockPessimistic
If rs.BOF = False Then
    MsgBox "The Product Code is Already Exist!", vbCritical
    If rs.State Then rs.Close
    Set rs = Nothing
    Exit Sub
Else
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.