You might try something like the following. This uses a subquery that is
built on the basis of query 13.
In Access, you can't use a subquery that reguires square braces []
embedded in the subquery. Since your field and table names meet the
requirements you can simply paste the subquery into the query. It must be
surrounded by [] and given an alias. Also, the last brace must be
followed by a dot (period).
So I changed this
... tblEmployees LEFT JOIN Query13 ...
To this
... tblEmployees LEFT JOIN [].Query13 ...
and then did this
... tblEmployees LEFT JOIN [<Paste or type the subquery>].Query13 ...
I ended up with this after I cleaned up the query. Note that I removed
all the grouping and used DISTINCT since you were not performing any
aggregation. Also I dropped the ORDER By clause in "query13" since it
should be ignored in a subquery.
SELECT DISTINCT tblEmployees.EmployeeID
, [EmpFirstName] & " " & [EmpLastName] AS Emp
, tblEmployees.EmpSignedIN
, tblJobNames.JobType, tblEmployees.EmpCashedOut
, Query13.ChkServer
FROM tblJobNames INNER JOIN ((tblEmployees
LEFT JOIN [
SELECT tblChecks.ChkServer
, EmpFirstName & " " & EmpLastName AS EMP
, tblChecks.ChkPaid
, tblChecks.ChkPrinted
, tblChecks.ChkCancelled
FROM tblEmployees INNER JOIN tblChecks
ON tblEmployees.EmployeeID = tblChecks.ChkServer
WHERE (tblChecks.ChkPaid=0
AND tblChecks.ChkPrinted=0
AND tblChecks.ChkCancelled=-1)
OR (tblChecks.ChkPaid=0
AND tblChecks.ChkPrinted=-1
AND tblChecks.ChkCancelled=0)
]. AS Query13 ON
tblEmployees.EmployeeID = Query13.ChkServer)
INNER JOIN tblJobsEmp ON
tblEmployees.EmployeeID = tblJobsEmp.EmployeeID)
ON tblJobNames.JobNameID = tblJobsEmp.JobID
WHERE tblEmployees.EmpSignedIN=-1
AND tblJobNames.JobType <> 3
AND tblEmployees.EmpCashedOut=0
AND Query13.ChkServer Is Null
ORDER BY [EmpFirstName] & " " & [EmpLastName];
'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
Sure, Thanks Doug.
I have this subquery thing happening, and once again I'm having a tuff
time.
Here are the 2 queries.
Query13
SELECT tblChecks.ChkServer, [EmpFirstName] & " " & [EmpLastName] AS EMP,
tblChecks.ChkPaid, tblChecks.ChkPrinted, tblChecks.ChkCancelled
FROM tblEmployees INNER JOIN tblChecks ON tblEmployees.EmployeeID =
tblChecks.ChkServer
GROUP BY tblChecks.ChkServer, [EmpFirstName] & " " & [EmpLastName],
tblChecks.ChkPaid, tblChecks.ChkPrinted, tblChecks.ChkCancelled
HAVING (((tblChecks.ChkPaid)=0) AND ((tblChecks.ChkPrinted)=0) AND
((tblChecks.ChkCancelled)=-1)) OR (((tblChecks.ChkPaid)=0) AND
((tblChecks.ChkPrinted)=-1) AND ((tblChecks.ChkCancelled)=0))
ORDER BY [EmpFirstName] & " " & [EmpLastName];
This is what I want.......
Query12
SELECT tblEmployees.EmployeeID, [EmpFirstName] & " " & [EmpLastName] AS
Emp, tblEmployees.EmpSignedIN, tblJobNames.JobType,
tblEmployees.EmpCashedOut, Query13.ChkServer
FROM tblJobNames INNER JOIN ((tblEmployees LEFT JOIN Query13 ON
tblEmployees.EmployeeID = Query13.ChkServer) INNER JOIN tblJobsEmp ON
tblEmployees.EmployeeID = tblJobsEmp.EmployeeID) ON tblJobNames.JobNameID
= tblJobsEmp.JobID
GROUP BY tblEmployees.EmployeeID, [EmpFirstName] & " " & [EmpLastName],
tblEmployees.EmpSignedIN, tblJobNames.JobType, tblEmployees.EmpCashedOut,
Query13.ChkServer
HAVING (((tblEmployees.EmpSignedIN)=-1) AND ((tblJobNames.JobType) Not
Like 3) AND ((tblEmployees.EmpCashedOut)=0) AND ((Query13.ChkServer) Is
Null))
ORDER BY [EmpFirstName] & " " & [EmpLastName];
What I'd like to do is eliminate the Queries and do this strictly SQL,
right now it's just SQL from the Query grid.
Once again,
Thank you,
DS
Douglas J. Steele said:
Can you give some idea of what it is you're trying to do?
--
Doug Steele, Microsoft Access MVP
(no private e-mails, please)
This is just a starting point but I need to run 2 queries I'm guessing.
The first query would tell me what records not to include in the second
query. Are there any examples of this?
Thanks
DS