# Thread: DCount() Function Criteria (2003)

1. ## DCount() Function Criteria (2003)

I'm trying to use the QryCountHours query in the attached mdb to count how many hours an appliance has worked during the day.
On the startup form, please set begin date to 01/01/2006 and end date to 30/06/2006 and run the QryCountHours query. You can see that the ore_f column displays zeroes throughout while it should hold 24 for most of the days.
Here's the QryCountHours query:
<font color=448800>SELECT DCount("giorno","query14","giorno = " & previsioni.giorno) AS ore_f, Previsioni.Giorno
FROM (Previsioni INNER JOIN Vap1 ON Previsioni.Giorno=Vap1.GIORNO) INNER JOIN Vap2 ON Previsioni.Giorno=Vap2.GIORNO
GROUP BY Previsioni.Giorno
HAVING (((Previsioni.Giorno) Between forms!Grafici!text0 And forms!Grafici!text2));</font color=448800>

2. ## Re: DCount() Function Criteria (2003)

Why do you include Vap1 and Vap2?
Why do you use Query14?
Why do you use DCount?

Doesn't the following query based on Previsioni do what you want?

SELECT Giorno, Count(Ora) AS Ore_f
FROM previsioni
WHERE [1kWh] Is Not Null OR [2kWh] Is Not Null
GROUP BY Giorno
HAVING Giorno Between [forms]![Grafici]![text0] And [forms]![Grafici]![text2]

3. ## Re: DCount() Function Criteria (2003)

You're right as usual Hans.
The fact is the original QryCountHours query drew fields from Vap1 and Vap2 as well but your solution works all the same <img src=/S/smile.gif border=0 alt=smile width=15 height=15>.
<img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•