View Full Version : Why my DCOUNT() Not work in a report??


alexkong2003
09-06-2006, 10:55 PM
Hi all,

May i know how to make my DCount()work in the report? I have Sex field with hundred of my Male or Female value in the table. Now i would like to Seperate these male and female to a group count of number, I had try to use DCount() function to count the male or female column, but the out put giving me an error message? Why? (my Control Source is =DCount("*","[EmployeeName]","[Sex]='Male'")) Is there any problem?

And now another problem... also from the report. I have quite many of sub total in a total field, how to add all of them together to a grand total in the report? Thank you.

regard,
alex

Ron_dK
09-06-2006, 11:09 PM
You might try this as a control source (query) :

SELECT Count(DCount("[sex]","Yourtable","")) AS [all], Yourtable.sex
FROM Yourtable
GROUP BY Yourtable.sex
HAVING (((Yourtable.sex) Like "male*"));

Hth


Please delete all your double post on this in other subforums.

Rich
09-06-2006, 11:27 PM
http://www.access-programmers.co.uk/forums/showthread.php?t=114053

alexkong2003
09-07-2006, 12:15 AM
I am sorry about posting too much same title in the forum, cause my adsl line got a little bit problem..

Thanks for the reply rich~~ i really appreciate that. but as the code u post it to me, i had try to put in the report (Control Source), but the report pop out an error message of syntax error missing operator in query expression. i had try many ways to figure what is the problem of the message but no result. so may i know what is happening there?

Rich
09-07-2006, 12:54 AM
Does the Report show all the employees in the table?

Ron_dK
09-07-2006, 02:40 AM
http://www.access-programmers.co.uk/forums/showthread.php?t=114053

Rich,
Can't open this thread, message :

Invalid Thread specified. If you followed a valid link, please notify the administrator


?? :confused:

Rich
09-07-2006, 02:02 PM
Duplicate posts Ron, which I suspect have now been removed;)

alexkong2003
09-07-2006, 05:06 PM
No it didn't Rich.... Because i didn't put any of the employee name field in the report... I do try and try but the dcount still not work in my report ... Help!!!

alexkong2003
09-07-2006, 07:26 PM
Hi all,
Actually I just make it. I mean the DCount() function I had make it in the report ... but~~~ why the Dcount() is counting all the record in the table but not counting group of record with the criteria? Can i do it with just counting on group of the record? Ex. I have a Sex field in a table, i can do it dcount 10 male or 10 Female in the table but how if i want to do it with separate with group A i have 2 male, group B i have 5 male and C have 3???

Rich
09-09-2006, 02:04 AM
Since it would appear that you only want a count of the records on the Report as grouped in the Report you can do the following.
In the Group footer add an unbound textbox, set its control source to
=Sum(Iif([Sex]="Male",1,0)) repeat the process and change the criteria to "Female"
For a grand total over the entire report repeat the method again in the Report Footer

alexkong2003
09-10-2006, 05:56 PM
You r Billion Rich !!! It works!! Thank you so much !!