Are Nulls Covered?

D

DS

I was wondering. Is the return of a null value covered.

Dim rs As DAO.Recordset
Dim rs2 As DAO.Recordset

Set rs = CurrentDb.OpenRecordset("SELECT Count(*) FROM " & _
"[MS Access;Database=\\Backoffice\C$\Warehouse\History.mdb].tblVoidDetails "
& _
"WHERE CDBizDay BETWEEN " & Format(Forms!frmReportDates!TxtStart,
"\#yyyy\-mm\-dd\#") & _
"AND " & Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#"),
dbOpenSnapshot)

Set rs2 = CurrentDb.OpenRecordset("SELECT Count(*) FROM " & _
"tblVoidDetails " & _
"WHERE CDBizDay BETWEEN " & Format(Forms!frmReportDates!TxtStart,
"\#yyyy\-mm\-dd\#") & _
"AND " & Format(Forms!frmReportDates!TxtEnd, "\#yyyy\-mm\-dd\#"),
dbOpenSnapshot)

Me.TxtVoids = rs(0) + rs2(0)
rs.Close
rs2.Close

Does the rs(0) mean if it's null that it's 0?
Thanks
DS
 
K

Ken Snell \(MVP\)

No. rs(0) refers to the first field in the rs recordset, which would be the
Count(*) field.

If you want to substitute a zero for a Null value, use the Nz function:

Me.TxtVoids = Nz(rs(0), 0) + rs2(0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Syntax Error 4
Not returning a value 7
Criteria Mismatch 4
DCount Syntax 2
ISAM Error 2
DCount In Otherdb 27
From External Database 5
trouble printing variavel 1

Top