I'm trying to test for No Current Record in a DAO recordset. It happens
when my strSQL returns a blank recordset from the db. I was trying to use
IsNull(rs(0)) or IsNull(rs.Fields(0)) but they don't work. Any suggestions?
Alex Dybenko - 05 May 2005 15:06 GMT
try to check for EOF property:
if not rs.EOF then
...

Signature
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com
> I'm trying to test for No Current Record in a DAO recordset. It happens
> when my strSQL returns a blank recordset from the db. I was trying to use
> IsNull(rs(0)) or IsNull(rs.Fields(0)) but they don't work. Any
> suggestions?
Rob - 05 May 2005 15:11 GMT
Bill
If I may suggest the following:
dim dbs as DAO.Database
dim rst as DAO.Database
Set dbs = CurrentDB()
Set rst = dbs.OpenRecordSet("Select FirstName From Table1")
' Here's the keypoint....
If not (rst.bof and rst.eof) Then
' There is data in the recordset
Else
' There is no data in the recordset
End If
Set rst = nothing
Set dbs = nothing
HTH
Rob

Signature
FMS Professional Solutions Group
http://www.fmsinc.com/consulting
Software Tools for .NET, SQL Server, Visual Basic & Access
http://www.fmsinc.com
FMS Advanced Systems Group
http://www.fmsasg.com/
> I'm trying to test for No Current Record in a DAO recordset. It happens
> when my strSQL returns a blank recordset from the db. I was trying to use
> IsNull(rs(0)) or IsNull(rs.Fields(0)) but they don't work. Any
> suggestions?
Jim C. - 05 May 2005 19:31 GMT
Hi,
One other alternative is to check that rst.RecordCount > 0.
Jim
> I'm trying to test for No Current Record in a DAO recordset. It happens
> when my strSQL returns a blank recordset from the db. I was trying to use
> IsNull(rs(0)) or IsNull(rs.Fields(0)) but they don't work. Any suggestions?