title: Why extremely occasionally will one of bof/eof be true for a new non-empty recordset
body: <pre><code> set recordsetname = databasename.openrecordset(SQLString)
      if recordsetname.bof &lt;&gt; true and recordsetname.eof &lt;&gt; true then
      'do something
      end if
  </code></pre>
  
  <p>2 questions :</p>
  
  <ol>
  <li><p>the above test can evaluate to false incorrectly but only extremely rarely
  (I've had one lurking in my code and it failed today, I believe for the first time in 5 years of daily use-that's how I found it). Why very occasionally will one of bof/eof be true for a non-empty recordset. It seems so rare that I wonder why it occurs at all.</p></li>
  <li><p>Is this a foolproof replacement:</p>
  
  <pre><code>if recordsetname.bof &lt;&gt; true or recordsetname.eof &lt;&gt; true then
  </code></pre></li>
  </ol>
  
  <p><strong>Edit to add details of code :</strong></p>
  
  <p>Customers have orders, each order begins with a <code>BeginOrder</code> item and end with an <code>EndOrder</code> item and in between are the items in the order.</p>
  
  <p>The SQL is:</p>
  
  <pre><code>' ids are autoincrement long integers '
  SQLString = "select * from Orders where type = OrderBegin or type = OrderEnd"           
  
  Dim OrderOpen as Boolean
  OrderOpen = False
  
  Set rs = db.Openrecordset(SQLString)
  If rs.bof &lt;&gt; True And rs.eof &lt;&gt; True Then
      myrec.movelast
      If rs.fields("type").value = BeginOrder Then
           OrderOpen = True
      End If
  End If
  
  If OrderOpen F False Then
      'code here to add new BeginOrder Item to Orders table '
  End If
  
  ShowOrderHistory 'displays the customer's Order history '
  </code></pre>
  
  <p>In this case which looks this this</p>
  
  <pre><code>BeginOrder
  Item a
  Item b
  ...
  Item n
  EndOrder
  
  BeginOrder
  Item a
  Item b
  ...
  Item n
  EndOrder
  
  BeginOrder
  Item a
  item b
  ...
  Item m
  
  BeginOrder     &lt;----should not be there as previous order still open
  </code></pre>