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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a where clause

Status
Not open for further replies.

Dom606

IS-IT--Management
Joined
Jul 29, 2007
Messages
123
Location
US
I have the following query as the record source for a report. I cannot seem to get the WHERE clause to evaluate the two conditions between the OR statement correctly. I tried several ways to enclose the two conditions with parentheses but must be doing something wrong.

Code:
SELECT tblProjects.[Project Name], Employees.[Last Name], Employees.[First Name], tblAssignments.[Assignment Start Date], tblAssignments.[Assignment End Date], tblAssignments.[Assignment Percent Utilized], tblProjects.[Project Category], Employees.Empl_Status
FROM tblProjects INNER JOIN (Employees INNER JOIN tblAssignments ON Employees.[Employee ID] = tblAssignments.[Employee ID]) ON tblProjects.ProjectID = tblAssignments.ProjectID
[COLOR=red]
WHERE (((tblAssignments.[Assignment Percent Utilized])<>0)) OR (((tblAssignments.[Assignment Percent Utilized])=0)) And (((tblAssignments.[ProjectID])=0))[/color]

ORDER BY tblProjects.[Project Name];
 
so what should the criteria be?

If you have:

Code:
WHERE [COLOR=red]([/color]tblAssignments.[Assignment Percent Utilized]<>0[COLOR=red])[/color] OR [COLOR=blue]([/color]tblAssignments.[Assignment Percent Utilized]=0 AND tblAssignments.[ProjectID]=0[COLOR=blue])[/color]

then you will get all records where [Assignment Percent Utilized]<>0 and you will also records where (tblAssignments.[Assignment Percent Utilized]=0 AND tblAssignments.[ProjectID]=0). Is that what you need?

Leslie

Have you met Hardy Heron?
 
Hi Leslie,
What I need is to select records
if tblAssignments.[Assignment Percent Utilized]<>0
Or
if tblAssignments.[Assignment Percent Utilized]=0 AND tblAssignments.[ProjectID]=0)
 
ok, did you test the WHERE clause I posted? that's what it should do....


 
I tried your suggestion. It correctly performs the left side of the OR statement. However, I am not getting records that meet the criteria on right side of the OR statement.
 
Leslie, you are correct it does work as you suggested. I fat fingered the where statement.

Thank you so much. This was driving me nuts.
Dom
 
A simpler way:
WHERE tblAssignments.[Assignment Percent Utilized]<>0 OR tblAssignments.[ProjectID]=0

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PH. I guess there are many ways to skin that cat.
Unfortunately, I could not figure out any of them!

Thanks again for the help.
Dom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top