help with DCount()

P

Paul

I have a table, called tblEnd, containing two fields.

ID - number
EndDate - date

I am trying to put together a dcount() to tell me how many of a specified
ID, does not have a date in the EndDate field.

I.e. find all - ID = 6 and EndDate is empty

The ID has been taken from current record on a loaded form and passed to an
integer called curID

Here is where I have got to:

Dim Total as integer

Total = DCount("[ID]", "tblEnd", "[ID] =" & curID)
msgbox Total

Every time I try and put in an AND statement, to tell it to find all the
empty EndDate fields, it fails.

Can anyone point me in the right direction? - Cheers
 
D

David C. Holley

-Always post the code thats crapping out as it will show us what your
missing.
-The statement would be something to the effect of
DCount("[ID]", "tblEnd", "[ID] = " & curID & " AND IsNull([EndDate]) =
True")
 
M

Marshall Barton

Paul said:
I have a table, called tblEnd, containing two fields.

ID - number
EndDate - date

I am trying to put together a dcount() to tell me how many of a specified
ID, does not have a date in the EndDate field.

I.e. find all - ID = 6 and EndDate is empty

The ID has been taken from current record on a loaded form and passed to an
integer called curID

Here is where I have got to:

Dim Total as integer

Total = DCount("[ID]", "tblEnd", "[ID] =" & curID)
msgbox Total

Every time I try and put in an AND statement, to tell it to find all the
empty EndDate fields, it fails.


I think this will do that for you.

Total = DCount("*", "tblEnd", "[ID] =" & curID _
& " And EndDate Is Null")
 

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

Top