943,923 Members | Top Members by Rank

Ad:
Dec 18th, 2008
-1

help

Expand Post »
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 OLEDBystem 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
Reputation Points: 3
Solved Threads: 5
Posting Whiz in Training
ryan311 is offline Offline
254 posts
since Jul 2008
Dec 18th, 2008
0

Re: help

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. rs.Open "Select PCODE from Product WHERE PCODE = '" & Trim(Text1.Text) & "'", cn, adOpenKeyset, adLockPessimistic
  2. If rs.BOF = False Then
  3. MsgBox "The Product Code is Already Exist!", vbCritical
  4. If rs.State Then rs.Close
  5. Set rs = Nothing
  6. Exit Sub
  7. Else
Reputation Points: 26
Solved Threads: 40
Posting Whiz
aktharshaik is offline Offline
316 posts
since Aug 2008
Dec 19th, 2008
0

Re: help

thanks your my hero
Reputation Points: 3
Solved Threads: 5
Posting Whiz in Training
ryan311 is offline Offline
254 posts
since Jul 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Colored Cell in List box
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Embedding in VB





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC