title: How to Trigger Code with ComboBox Change Event
body: <p>I have a created a database containing historical stock prices.  On my form I have two comboboxes, <code>ComboBox_Ticker</code> and <code>ComboBox_Date</code>.  When these comboboxes are filled I want to check the database and see if the respective data exists in the database.  If it does I want to change the text of a label called <code>Label_If_Present</code> to "In Database".</p>
  
  <p>My problem occurs with the change event.  I want all of this to happen once I change the data in the textboxes.  I have tried both the <code>.TextChanged</code> and <code>.LostFocus</code> events.  The '.TextChanged' triggers the code to early and throws and error in my SQL command statement.  The `.LostFocus' event doesn't do trigger my code at all.  </p>
  
  <p>Here is my current code:</p>
  
  <pre><code>Public databaseName As String = "G:\Programming\Nordeen Investing 3\NI3 Database.mdb"
  Public con As New OleDb.OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =" &amp; databaseName)
  Public tblName As String = "Historical_Stock_Prices"
  
  Private Sub Change_Labels(ByVal sender As Object, ByVal e As EventArgs) Handles ComboBox_Ticker.TextChanged, ComboBox_Date.TextChanged
      con.Close()
      Dim dr As OleDbDataReader
      con.Open()
      If (File.Exists(databaseName)) Then
          Dim restrictions(3) As String
          restrictions(2) = tblName
          Dim dbTbl As DataTable = con.GetSchema("Tables", restrictions)
          If dbTbl.Rows.Count = 0 Then
          Else
              Dim cmd2 As New OleDb.OleDbCommand("SELECT * FROM " &amp; tblName &amp; " WHERE  Ticker = '" &amp; ComboBox_Ticker.Text &amp; "' " &amp; "  AND  Date1 = '" &amp; ComboBox_Date.Text &amp; "'", con)
              dr = cmd2.ExecuteReader
              If dr.Read() = 0 Then
                  'If record does not exist
                  Label_If_Present.Text = ""
              Else
                  Label_If_Present.Text = "In Database"
              End If
              con.Close()
          End If
      Else
      End If
  End Sub
  </code></pre>
  
  <p>I have successfully implemented this concept on other forms within my project.  This one is slightly different and I can't figure out why I can't get this one to work.  </p>