I'm trying to fill a textbox according to another textbox value while searching the Table
first textbox is txtMjrCode and the other is txtMjrName, I want the txtMjrName fills if the txtMjrCode value does exist in tblMajors.
I've wrote the code below but it has a big problem! for example if there is a "100" for mjrCode
in the table and I type "100" in txtMjrCode, the txtMjrName shows "x" and if I go on and type "1000" and this value does not exist in the table, I want the second textbox get empty but it doesn't and continues showing "x"!
Private Sub txtMjrCode_Change() Set rs3 = New ADODB.Recordset With rs3: .Open "Select * from tblMajors", cn, 2, 3 Do While Not .EOF If StrComp(!MjrCode, txtMjrCode.Text) = 0 Then txtMjrName.Text = !MjrName If !MjrProvider = True Then cboType = "pro" Else cboType = "elem" Exit Do Else .MoveNext End If Loop End With End Sub