Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick Dcount question 1

Status
Not open for further replies.

snayjay

Programmer
Oct 23, 2001
116
US
I'm trying to find the number of records in a table where the TIMEOUT field has yet to be filled in.

Code:
xck = DCount("[VID]", "VLtbl", "[TIMEOUT] = " & Null)

It's not working... and I thought maybe TIMEOUT was a reserved name, but I tried something else and it still didn't work. Am I doing something wrong with trying to use Null? Any help would be appreciated. Thanks in advance,

Snay
 
1 = 1 is always true
1 = 2 is always false
x = Null is always null (and thus, never true or false)

Think of Null as meaning "I don't know."
Does x = Some value that I don't know? I don't know.

In DCount(and many other places), the expression must evaluate to true in order for it to work.

I think the solution posted by JerryKlmns should work, but if not, try:

xck = DCount("[VID]", "VLtbl", "IsNull([TIMEOUT])")
 

Another possibility...
xck = DCount("VID", "Vtbl", "IsNull(TIMEOUT) OR TIMEOUT = """")

Randy
 
Randy,

That only works if TIMEOUT is a string value and "" is not a distinct choice from NULL. If this is the case, it would be easier to do this:

xck = DCount("VID", "Vtbl", "(Nz([TIMEOUT], "")="")")

(Extra () to improve readability)
 
Thanks for all the inputs... Jerry, I cut and pasted your answer and it didn't work... looked good, but didn't work. Korngeek, your first post worked great... thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top