View Full Version : Unexpected DCount results


Malcy
01-05-2005, 04:22 AM
Hi
I am trying to count valid records on a grouped report. I have used the following code in the ControlSource for the textbox

=DCount("bSup","tblPurpRev","lngCntRef = " & [txtCntRef] And [ysnSup]="-1 ")

The [txtCntRef] and [ysnSup] refer to controls on the report.

I set up test data which should have one grouping (lngCntRef = 1) giving a result of 5 and the other grouping (lngCntRef = 2) giving a result of 0
Instead what I get is 10 for the first group and 0 for the second.
What it seems to be doing is saying if [ysnSup] = -1 then count the total number of fields with a [ysnSup] checkbox, rather than just those records where the checkbox value is -1 (which is what I want it to do).
How can I correct this?
Any help would be most appreciated

namliam
01-05-2005, 05:40 AM
Your quotes are out of whack, but i hope thats a mispost

=DCount("bSup","tblPurpRev","lngCntRef = " & [txtCntRef] & " And [ysnSup]=-1 ")

Try it....

Regards

Malcy
01-05-2005, 06:06 AM
Thanks Namliam
That was it.
Looking at it I think I posted what I had after about 20 goes, all of which failed.
It looks so obvious and simple when I look at yours.
One day, perhaps, I will get the hang of this!!!
Thanks again and best wishes from a wet and windy Edinburgh