"DateWorked:" Asked as parameter but not desired

G

Guest

Here is the SQL code that I have to collect total overtime hours for a
specific time period. Right now, the query asks me for a date worked.
However, I would like it to ask me a section, and by entering the section
name, a query displays the total overtime hours for that section for a
specific date.

Thanks in advance.


SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE (((Year([DateWorked]))=2004))
GROUP BY WatchResults.Section;
 
K

Ken Snell [MVP]

Just add another criterion to the query:

SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE Year([DateWorked]=2004 And
WatchResults.Section = [Enter Section:]
GROUP BY WatchResults.Section;
 
G

Guest

OK.. It now asks me to Enter Section:, but it still asks me to enter
DateWorked:
I do not want to enter this date. I just want those results from this year
to be displayed

Ken Snell said:
Just add another criterion to the query:

SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE Year([DateWorked]=2004 And
WatchResults.Section = [Enter Section:]
GROUP BY WatchResults.Section;

--

Ken Snell
<MS ACCESS MVP>

Ty said:
Here is the SQL code that I have to collect total overtime hours for a
specific time period. Right now, the query asks me for a date worked.
However, I would like it to ask me a section, and by entering the section
name, a query displays the total overtime hours for that section for a
specific date.

Thanks in advance.


SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE (((Year([DateWorked]))=2004))
GROUP BY WatchResults.Section;
 
J

John Vinson

Here is the SQL code that I have to collect total overtime hours for a
specific time period. Right now, the query asks me for a date worked.
However, I would like it to ask me a section, and by entering the section
name, a query displays the total overtime hours for that section for a
specific date.

Thanks in advance.


SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE (((Year([DateWorked]))=2004))
GROUP BY WatchResults.Section;

Is there a field named DateWorked in WatchResults? The fact that
you're being prompted suggests that there is no such field or that the
fieldname is spelled differently. Is it perhaps [Date Worked]?

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
K

Ken Snell [MVP]

Then remove the criterion that asks for a year to be entered.

--

Ken Snell
<MS ACCESS MVP>

Ty said:
OK.. It now asks me to Enter Section:, but it still asks me to enter
DateWorked:
I do not want to enter this date. I just want those results from this year
to be displayed

Ken Snell said:
Just add another criterion to the query:

SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE Year([DateWorked]=2004 And
WatchResults.Section = [Enter Section:]
GROUP BY WatchResults.Section;

--

Ken Snell
<MS ACCESS MVP>

Ty said:
Here is the SQL code that I have to collect total overtime hours for a
specific time period. Right now, the query asks me for a date worked.
However, I would like it to ask me a section, and by entering the section
name, a query displays the total overtime hours for that section for a
specific date.

Thanks in advance.


SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE (((Year([DateWorked]))=2004))
GROUP BY WatchResults.Section;
 
K

Ken Snell [MVP]

And, to add to my other reply, if you're being asked for DateWorked, then
that means that you do not have a field named DateWorked in the WatchResults
table.

Perhaps, DateWorked was a generic name given to you by some other responder
who was answering a different question for you?
--

Ken Snell
<MS ACCESS MVP>


Ty said:
OK.. It now asks me to Enter Section:, but it still asks me to enter
DateWorked:
I do not want to enter this date. I just want those results from this year
to be displayed

Ken Snell said:
Just add another criterion to the query:

SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE Year([DateWorked]=2004 And
WatchResults.Section = [Enter Section:]
GROUP BY WatchResults.Section;

--

Ken Snell
<MS ACCESS MVP>

Ty said:
Here is the SQL code that I have to collect total overtime hours for a
specific time period. Right now, the query asks me for a date worked.
However, I would like it to ask me a section, and by entering the section
name, a query displays the total overtime hours for that section for a
specific date.

Thanks in advance.


SELECT WatchResults.Section, Sum(WatchResults.[Overtime Hours]) AS
[SumOfOvertime Hours]
FROM WatchResults
WHERE (((Year([DateWorked]))=2004))
GROUP BY WatchResults.Section;
 

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