Originally posted by Zac Harvey
Allen Browne explained the half of the story he dealt with. Let's see if we can give the complete picture for your perspective.
Code:
If rsDao.RecordCount > 0 Then
Code:
If Not (rsDao.BOF And rsDao.EOF) Then
Call rsDao.MoveLast
is required. Of course, this code shouldn't be executed without first checking that the recordset is empty otherwise it will fail.It seems then, that accurately determining the count in most recordsets (dbOpenTable is an exception) requires both techniques (Check records exist; Move to last). In this case though, I suspect you simply need the check, as the actual count is irrelevant. I would suggest, due to the confusing nature of what is required, that determining whether or not a recordset has any records should be done using the second of the two methods shown (
If Not (rsDao.BOF And rsDao.EOF) Then
) rather than the first. Disambiguation is definitely an aim to strive for when writing code unless you are interested in ensuring people don't understand it.PS. ** Edit **
Having reread and realised I missed something in the code, I would say here that, for the purposes of disambiguation (still very important) I would recommend using the first approach when simply determining if records exist, and the second prior to determining the accurate count of the recordset. They both do fundamentally the same job of course, but the first seems clearer as an indication of what's required. At the end of the day though, how it reads to you the developer is the most important factor here, so make your own choices.
Comment