Need help with query statement

lipin

Registered User.
Local time
Today, 12:17
Joined
May 21, 2002
Messages
149
I have this in part of a select statement that builds a table.

"FROM tblHistory " & _
"INNER JOIN tblActiveJobCd ON tblActiveJobCd.JobCd = tblHistory.JobCd " & _
"WHERE EntryDate >= #" & GoalWeek(x).StartDate & "# " & _
"AND EntryDate <= #" & GoalWeek(x).EndDate & "# " & _
"AND tblHistory.Train = 'N'" & _
"AND tblHistory.CostCd <> '0547'" & _
"GROUP BY tblHistory.JobCd " & _
"ORDER BY tblHistory.JobCd")

In the line: "AND tblHistory.Train = 'N'" & _
I am only selecting Trained Employees. (N denotes not in training)

My problem is that for JobCode 100 and 1500, I want it to select all employees. For all other JobCodes (200 thru 1300) it works fine the way it is.

How do I get both needs into this table?
Do I use another WHERE statement with different criteria statements? Or IF...Then... and where would it go?
 
Try:
Code:
"FROM tblHistory " & _
"INNER JOIN tblActiveJobCd ON tblActiveJobCd.JobCd = tblHistory.JobCd " & _
"WHERE EntryDate >= #" & GoalWeek(x).StartDate & "# " & _
"AND EntryDate <= #" & GoalWeek(x).EndDate & "# " & _
[B]"AND (tblHistory.Train = 'N' OR tblHistory.JobCd IN ('100','1500')) " & _[/B]
"AND tblHistory.CostCd <> '0547'" & _
"GROUP BY tblHistory.JobCd " & _
"ORDER BY tblHistory.JobCd")
See if this works for you.
 
Thanks!

Works Great!
 

Users who are viewing this thread

Back
Top Bottom