954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

help

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

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 
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
aktharshaik
Posting Whiz
316 posts since Aug 2008
Reputation Points: 26
Solved Threads: 40
 

thanks your my hero :D

ryan311
Posting Whiz in Training
254 posts since Jul 2008
Reputation Points: 3
Solved Threads: 5
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You