title: sql select statement in vb returning value when its supposed to be null
body: <p>My code seems to behave a way I don't understand. Sometimes it returns null as expected and sometimes it returns a value when its supposed to be null. How can someone explain this? Here is the code that selects from access and displays the result in a messagebox:</p>
  
  <pre><code>cmd5.Connection = cnn
  
  cmd5.CommandText = "SELECT receipt_num " &amp; _
           "FROM brought_coffee, farmer where crop_year= " &amp; yr &amp; " and " &amp; _
           "brought_date=#" &amp; dtt &amp; "# and farmer_centre='" &amp; ctr &amp; _
           "' and farmer.farmer_num=brought_coffee.farmer_num"
  
  myData5 = cmd5.ExecuteReader
  
  While myData5.Read()
     chkdb = myData5(0).ToString
  End While
  
  MsgBox("the check" &amp; chkdb)
  myData5.Close()
  </code></pre>