Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Problem filling a textbox connected to DB

$
0
0
Hi
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

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>