Hi all
My table (Access2k) contain records as this:
TABLE Product:
234
A11
ASW
ASWW
AWS
TABLE Stock:
234
A11
ASW
ASWW
In a form code I make like this:
my problem is:VB Code:
Private Sub txtProductID_LostFocus() Dim msql As String If txtProductID.Text <> "" Then con_Data.BeginTrans 'Find product id from stock table msql = "select * from stock " & _ " where productid='" & txtProductID.Text & "'" Set Rs = con_Data.Execute(msql) 'if product id found If Not Rs.EOF Then 'Display all fields txtProductName.Text = Rs.Fields("productname") txtUnit.Text = Rs.Fields("unit") mseOpeningStock.Text = Rs.Fields("openingstock") mseQuantity.Text = Rs.Fields("quantity") txtProductID.Enabled = False txtProductName.Enabled = False txtUnit.Enabled = False mseQuantity.Enabled = False mseOpeningStock.Enabled = False cmdAdd.Enabled = True cmdDelete.Enabled = True cmdEdit.Enabled = True Else 'find product id from product table msql = "select * from product " & _ " where productid='" & txtProductID.Text & "'" Set Rs1 = con_Data.Execute(msql) 'if product id found If Not Rs1.EOF Then 'Display fileds txtProductName.Text = Rs1.Fields("productname") txtUnit.Text = Rs1.Fields("unit") txtProductID.Enabled = False txtProductName.Enabled = False txtUnit.Enabled = False mseOpeningStock.Enabled = True cmdCancel.Enabled = True mseOpeningStock.SetFocus End If Rs1.Close End If Rs.Close con_Data.CommitTrans End If End Sub
When I type "AWS" in txtProductID it show "ASWW" and populate this record in textbox, and when I type "ASWW" or "ASW" or "234" or "A11" in txtProductID it work fine
I really appreciate if anyone can advice on my coding above.
thanks and "HAPPY NEW YEAR TO ALL"




support clasicVB6
Reply With Quote