Quote:
quote:Originally posted by woodyz
When first opening a recordset, your cursor is pointing at the first record if there is one. If there isn't, then it is pointing at EOF. I see a lot of sample code that checks BOF and EOF, but you only need to check BOF if you are navigating backwards.
|
Woody, this is largely true, but I am addressing it so that the poster will be clearer.
It is true that when you open a recordset, the first record is the current record, if there are any records.
If there are no records,
both .BOF (beginning of file) and .EOF (End of File) will be true. If .EOF is true (and that's all you know) then two situations are possible: there are no records, or you have run off the end. If .BOF is true (and that's all you know) then two situations are possible: there are no records, or you have run off the beginning of the recordset.
If you have run off the end, it is manifestly obvious that you are not at the beginning...
So if
both .Eâ [u]and</u> .BOF are true, there cannot be anything in between, you see. Checking for both guarantees that under any arrangement, if both are true the recorset is empty.
Now, again, when you open a RecSet the first record is currentâso the following is never necessary:
Code:
rs.Open
rs.MoveFirst
So, since the recset is not at .BOF, but is at the first record,
is a functional shorthand to test whether any records were returned. So is
Regarding using .Filter, you can use this, or you can use restriction language in the WHERE clause of the query. With .Filter, you actually return all of the records into the recordset, but you don't see them all. This can be advantageous if you are going to chnage the filter. This removes the necessity of getting records again. But if you are never going to alter which records you see, using a WHERE clause is easier on the computer resources, and probably ever-so-slightly faster.