MarkSweetland
MIS
I've seen a lot of sample code both here is the forum and in Microsoft's examples that determine whether or not a recordset is empty by checking if the BOF and EOF flags are both true.
For the most part I see:
But my contention is that it should be checked this way:
I think the order of operations indicates that the NOT operation will be performed before the AND operation. The resultant AND operation will be:
If both the BOF and EOF are true then the recordset is empty. If the BOF Flag is set, then the record pointer is at the begining of the recordset (not the first record). If the EOF is true then the record pointer is at the end of the recordset (not the last record). So the check
ensures operations on non-empty recordsets, but does not position the pointer to any particular record. I agree that the check is mostly conducted directly after the Open method is called but is it also guarenteed that the record pointer is at one end of the other?
Any thoughts?
Mark
For the most part I see:
Code:
If Not rs.BOF And Not rs.EOF Then
'<do something here>
End If,
But my contention is that it should be checked this way:
Code:
If Not (rs.BOF And rs.EOF) Then
'<do something here>
End If
I think the order of operations indicates that the NOT operation will be performed before the AND operation. The resultant AND operation will be:
Code:
'BOF 'EOF ANDED NOT-BOF NOT-EOF ANDED-NOTs
0 0 0 1 1 1
1 0 0 0 1 0
0 1 0 1 0 0
1 1 1 0 0 0
Code:
If Not (rs.BOF And rs.EOF) Then
'<do something here>
End If
ensures operations on non-empty recordsets, but does not position the pointer to any particular record. I agree that the check is mostly conducted directly after the Open method is called but is it also guarenteed that the record pointer is at one end of the other?
Any thoughts?
Mark