Are Nulls Covered?

  • Thread starter Thread starter DS
  • Start date Start date
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
 
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)
 
Back
Top