SaladSnake
SaladSnake

Reputation: 167

Counting records where a particular field is Null

So I have this code that looks in the [CanDate] field and tries to find all the records where it is Null. My problem is that I have 3 records that are Null but it's only finding 1. Can anyone suggest why that might be?

Here's my code

Set rsCanCounter = db.OpenRecordset("Select * from tblGroupHeader Where CanDate IS NULL", dbOpenDynaset)
canCount = rsCanCounter.RecordCount
If canCount = 0 Then
    txtOpenAction.Value = 0
Else
    txtOpenAction.Value = canCount
End If

Upvotes: 3

Views: 109

Answers (1)

AdamsTips
AdamsTips

Reputation: 1776

If you just need a simple count, you might consider the DCount function...

CanCount = DCount("*", "tblGroupHeader", "CanDate IS Null")

Upvotes: 4

Related Questions