Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

still need more expressions for my DCount criteria . . . . . .

Status
Not open for further replies.

SnoWBunnY

Programmer
Jul 4, 2002
13
CA
Hi!

I had posted a question about the DCount function a few days ago and CosmoKramer was able to help me out a bit but my expression is still not complete and I am running out of ideas as to how to solve this problem.

I have created a report for viewing information on the People Affected but before viewing this report, from a form, you must select who is affected from the option group .... "1" = Employee, "2" = Patient, "3" = Visitor / Volunteer, the value goes into the [PersonAffected] field. and then you select the beginning date and the ending date.

Now, on my report I have a summary box with the following information:

2002 Summary:

Quarter: #Incidents #EmplInci #PtInci #V/VInci
1 1 0 0 1
2 1 0 1 0
3 15 4 8 3
4 1 0 1 0
----- ----- ----- -----
Totals: 18 4 10 4

but this is not the data that I am getting because the DCount expression that have is not functional or complete at this time.
Here is an example of it:
=DCount("[PersonAffected]","IncidentsByPersonQuery","[PersonAffected]='2' AND DatePart('q',[DateIncident])=1 AND DatePart('yyyy',[DateIncident])=[Year]")

so what I want to do is count how many Patients have been affected, then how many employees and then how many visitor/volunteers have been affected. When I count them, I want the sums to be displayed into the right quarters and per year. The way that my DCount is working now is that it's counting the incidents for all of the patients but for all of the years. So I need something else in my criteria to count only the Patients affected for that year only (lets say 2001) then on the next year only patients for that year (2002) and so on......
 
SB,

Can you send me a zipped copy of the db so I can take a look at it??

sw3540@yahoo.com
 
Corinne,

You actually need less expressions, not more.

I changed the control source of the three total fields to be the same as their respective columns, but I took out the "DatePart('q',[DateIncident])=1" part of the criteria. So, for the "Employees" total field (text57), it should now be:
Code:
=DCount("[PersonAffected]","IncidentsByPersonQuery","[PersonAffected]='1' AND DatePart('yyyy',[DateIncident])=[Year]")

Change the PersonAffected number for the other totals and you should be all set.

From what I could see, it is now returning the right values.....

Let me know what you think.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top