DCount Question

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
 
W

williamr

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
 
B

Baz

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).
 
L

Linq Adams via AccessMonster.com

You need square brackets around your field names!

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

Tom Lake

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
 
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
 
W

williamr

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
 
B

Baz

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?
 
W

williamr

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?
 

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