DCount Question

  • Thread starter Thread starter williamr
  • Start date Start date
W

williamr

Would someone please correct my code for me, please! I' want to count a
field named "returned", in a table named "Table1" if both the fields
"Returned & Resent are true.

=DCount("returned","Table1","returned=true and "resent= true")

Thank You
 
Baz, Hi. That does not work. I have 5 items in that field and only 2 are
true. Both fields are "Yes/No". I've changed the default to "True/False"
but it counts all 5 records
 
If it doesn't give you an error then it's working, Access doesn't simply
invent incorrect results. There is something you are overlooking or some
piece of information you are not giving us.

I am puzzled by "I've changed the default to "True/False"". You can't set
the default value of a Yes/No field to a string like that, it must be either
True or False (or 0 or -1, which amounts to the same thing).
 
You need square brackets around your field names!

DCount("[returned]", "Table1", "[returned]=true and [resent]= true")

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
Linq Adams via AccessMonster.com said:
You need square brackets around your field names!

DCount("[returned]", "Table1", "[returned]=true and [resent]= true")

Only if they include a space. Returned Value would need brackets
but Returned doesn't.

Tom Lake
 
williamr said:
Would someone please correct my code for me, please! I' want to count a
field named "returned", in a table named "Table1" if both the fields
"Returned & Resent are true.

=DCount("returned","Table1","returned=true and "resent= true")

You have mismatched quotation marks.
The following works for me (I copied and pasted it right out of a module):

DCount("returned", "Table1", "returned=true and resent=true")

Tom Lake
 
OK, I’m sorry for not giving the complete story but I had the first column
working and thought it unimportant to provide that working part. In the
future I will include all code.
=DCount("daterelease","Table1","DateDiff('m', daterelease, Now)=0" - -
This code counts the releases for this month, it works fine. - - Now I want
to count the releases that were returned for the month so I added this code -
- And "returned=yes And Resent=No")

Thanks Again
 
So what you want is this?

=DCount("daterelease","Table1","DateDiff('m', daterelease, Now)=0 And
returned=yes And Resent=No")

Although I thought you were checking both Booleans for True earlier?
 
That's perfect!
Thank You!!!

Baz said:
So what you want is this?

=DCount("daterelease","Table1","DateDiff('m', daterelease, Now)=0 And
returned=yes And Resent=No")

Although I thought you were checking both Booleans for True earlier?
 
Back
Top