R
Randy
Ken you helped me last week with a query to find missing dates from my
employee db. It works great except I have found that it returns all dates
from my employee database which contains approx 1000 employees. This is a
statewide employee table. I need it to return only currently working
employees (About 25). When I return an employee from furlough or re-hire
them I enter data of "First Day" which has a coresponding code of 50 into my
table of "IDRb" which is a table used for the subform of my "IDR" form.,
for the first day back to work and I enter "Last Day' which has a
coresponding code of 60 for the last day worked for the season. The codes
50 and 60 are selected from a table of "CommCode" by a combo box. This is
my last hurdle before I can distribute the db to other offices...Thank
you..Randy
employee db. It works great except I have found that it returns all dates
from my employee database which contains approx 1000 employees. This is a
statewide employee table. I need it to return only currently working
employees (About 25). When I return an employee from furlough or re-hire
them I enter data of "First Day" which has a coresponding code of 50 into my
table of "IDRb" which is a table used for the subform of my "IDR" form.,
for the first day back to work and I enter "Last Day' which has a
coresponding code of 60 for the last day worked for the season. The codes
50 and 60 are selected from a table of "CommCode" by a combo box. This is
my last hurdle before I can distribute the db to other offices...Thank
you..Randy
qryAll query:
-------------
SELECT EMP.EID, Dates.D
FROM EMP, Dates
WHERE (((Dates.D) Between [Enter Beginning Date] And
[Enter Ending Date]));
qryGaps query:
---------------
SELECT Q.EID, Q.D
FROM qryAll AS Q LEFT JOIN IDRa AS W
ON (Q.EID = W.Eid) AND (Q.D = W.Current_Date)
WHERE (((Q.EID) Like 2045) AND ((W.Eid) Is Null))
ORDER BY Q.EID, Q.D;
--
Ken Snell
<MS ACCESS MVP>
Randy said:IDRa_ID Eid Current_Date District_Id TotalHours TotalMiles TotalFees
tblMonth StateMiles StateLicense Expenses AccountID
865 2045 7/18/2005 764 8 48 $0.00 7 0 $0.00
866 2045 7/19/2005 764 8 142 $0.00 7 0 $0.00
867 2045 7/20/2005 764 8 38 $0.00 7 0 $0.00
869 2045 7/22/2005 764 8 0 $0.00 7 0 $0.00
870 2045 7/23/2005 764 0 0 $0.00 7 0 $0.00
D
2/18/2005
2/19/2005
2/20/2005
2/21/2005
2/22/2005
2/23/2005
2/24/2005
2/25/2005
2/26/2005
2/27/2005
2/28/2005
Emp_ID EID Ename Payroll HQ_Dist
1 2045 John Smith P 764
I hope this comes out ok..
Ken Snell said:No, what I'm asking is that you post the actual data from the tables for
records that contain a value of 2045 for the EID and/or the value of
2/21/05 for the Current_Dat. I need to see the actual data so that I can
see how the query is selecting the records. As I noted, I expect the
problem is because the query is not designed quite right to match your
data, and seeing your actual data records will help me identify what I
need to change in the query structure that I suggested.
--
Ken Snell
<MS ACCESS MVP>
The query returns 11 times EID with data of 2045, and Current_Date with
data of 2/21/05 which is the actual missing date. Thanks again.
Also show the data for the specific example that you say is returning
11 records of the same employee/date combination. I need to see the
data from all the tables that relate to that specific employee and
date.
--
Ken Snell
<MS ACCESS MVP>
Here are the three tables used. I really appreciate your help..Randy
1st table: "IDRa" With primary key of [IDRa_ID] (AutoNumber) and
[EID] (Number), [Current_Date] (Date/Time), [District_ID] (Number),
[TotalHours] (Number), [TotalMiles] (Number), [TotalFees] (Currency)
2nd table: "EMP" with primary key of [EMP_ID] (Autonumber), [EID]
(Number), [EName] (Text), [Payroll] (Text), [HQ_Dist] (Number)
3rd table: "Dates" with one field [D] (Date/Time)
I'd need to see your data to provide a suggestion. My initial
thought is that we need one more join in the second query, but I
don't know that until I see what your entire table structure and
data values are. Can you post that information?
--
Ken Snell
<MS ACCESS MVP>
I'm getting closer, I made a few changes to the sql. I now get the
missing date, but the result is 11 records of the same missing
date..Any thoughts..Thanks..Ken....Randy
SELECT [EMP].[EID], [Current_Date]
FROM EMP, IDRa
WHERE Current_Date Between [Enter Beginning Date] And [Enter Ending
Date];
SELECT Q.EID, Q.Current_Date
FROM qryAll AS Q LEFT JOIN IDRa AS W ON (Q.EID = W.Eid) AND
(Q.Current_Date = W.Current_Date)
WHERE (((Q.EID) Like 2045) AND ((W.Eid) Is Null));