I use this function to not worry about NULL values ββwhen reading record sets:
Public Function toStr(pVar_In As Variant) As String On Error Resume Next toStr = CStr(pVar_In) End Function
Never trust the exact value of rec.recordcount , but rec.RecordCount>0 is safe. This is why you should never use a for loop when using a recordset. If you want to know the record number anyway, what you need to do is rec.movelast and then rec.movefirst
There are two different ways that I know:
While not rec.eof msgbox toStr(rec!CtyMarket) rec.moveNext Wend
or
While not rec.eof msgbox toStr(rec.fields("CtyMarket").value) rec.moveNext Wend
source share