J
JWeaver
NOTE: I posted the following message at the beginning of June but haven't had
the time to try the response until now and was wondering just how do I go
about trying to make this happen? Where do I put the code, in a query or in
a report? Can I just copy and paste the code or do I have to do other things
to it to make it work?
----
We have employees who are to provide Notes regarding clients on a weekly
basis. I want to be able to produce a report that will indicate the name of
any client where Notes were not submitted. I track these Notes using a Start
Date and End Date.
Right now, I sort the records based on client name and dates and then do a
visual search of the printed pages but as the report gets bigger, this task
will take longer and longer. Is there a way to compare 2 start dates and if
there is more than 7 days between them to return the client name on a report
along with the dates that are missing? If so, it would help me tremendously!
Table Structure (Name: Wrap Payroll):
PPE Date - Date/Time
Advocate Last - Text
Advocate First - Text
Emp # - Text
Pay Rate - Number
First - Text (this is the client name)
Last - Text (client)
Program - Text
Con Hours - Number
Con Date - Date/Time
From - Date/Time (this is the start date of week for Notes)
To - Date/Time (this is the end date of week)
Hours - Number
ID - AutoNumber
Dups OK - Text
Note - Text
Sample Date:
PPE Date - 05/23/2008
Advocate Last - Smith
Advocate First - John
Emp # - 012345
Pay Rate - 14.00
First - Julie
Last - Adams
Program - PAL
Con Hours - 25
Con Date - 07/01/08
From - 05/31/08
To - 06/06/08
Hours - 25
ID - AutoNumber
Dups OK - "Blank"
Note - Worked 25 this week.
-----
Response by Karl Dewey:
I used table name JWeaver (I changed this to Wrap Payroll) and first query
named JWeaver_1 (Changed to Wrap Payroll_1). These give you the record that
is more than 7 days from the previous one.
SELECT Q.[Advocate Last], Q.[Advocate First], Q.From, (SELECT COUNT(*) FROM
Wrap Payroll Q1
WHERE Q1.[Advocate Last] = Q.[Advocate Last]
AND Q1.[Advocate First] = Q.[Advocate First]
AND Q1.From < Q.From)+1 AS Rank
FROM Wrap Payroll AS Q
ORDER BY Q.[Advocate Last], Q.[Advocate First], Q.From;
SELECT Wrap Payroll_1.Rank, Wrap Payroll.*
FROM (Wrap Payroll INNER JOIN Wrap Payroll ON (Wrap Payroll.[Advocate First]
=
Wrap Payroll.[Advocate First]) AND (Wrap Payroll.[Advocate Last] =
Wrap Payroll.[Advocate Last])) INNER JOIN Wrap Payroll AS Wrap Payroll_1 ON
(Wrap Payroll.From = Wrap Payroll_1.From) AND (Wrap Payroll.[Advocate First]
=
Wrap Payroll_1.[Advocate First]) AND (Wrap Payroll.[Advocate Last] =
Wrap Payroll_1.[Advocate Last])
WHERE (((Wrap Payroll_1.Rank)=[Wrap Payroll].[Rank]+1) AND
((DateDiff("d",[Wrap Payroll].[From],[Wrap Payroll_1].[From]))>7));
This will give you the records that is followed by more than 7 days ---
SELECT Wrap Payroll_1.Rank, Wrap Payroll.*
FROM (Wrap Payroll INNER JOIN Wrap Payroll ON (Wrap Payroll.From = Wrap
Payroll.From) AND
(Wrap Payroll.[Advocate First] = Wrap Payroll.[Advocate First]) AND
(Wrap Payroll.[Advocate Last] = Wrap Payroll.[Advocate Last])) INNER JOIN
Wrap Payroll
AS Wrap Payroll_1 ON (Wrap Payroll.[Advocate First] = Wrap
Payroll_1.[Advocate First])
AND (Wrap Payroll.[Advocate Last] = Wrap Payroll_1.[Advocate Last])
WHERE (((Wrap Payroll_1.Rank)=[Wrap Payroll].[Rank]+1) AND
((DateDiff("d",[Wrap Payroll].[From],[Wrap Payroll_1].[From]))>7));
Any help is greatly appreciated!!!
the time to try the response until now and was wondering just how do I go
about trying to make this happen? Where do I put the code, in a query or in
a report? Can I just copy and paste the code or do I have to do other things
to it to make it work?
----
We have employees who are to provide Notes regarding clients on a weekly
basis. I want to be able to produce a report that will indicate the name of
any client where Notes were not submitted. I track these Notes using a Start
Date and End Date.
Right now, I sort the records based on client name and dates and then do a
visual search of the printed pages but as the report gets bigger, this task
will take longer and longer. Is there a way to compare 2 start dates and if
there is more than 7 days between them to return the client name on a report
along with the dates that are missing? If so, it would help me tremendously!
Table Structure (Name: Wrap Payroll):
PPE Date - Date/Time
Advocate Last - Text
Advocate First - Text
Emp # - Text
Pay Rate - Number
First - Text (this is the client name)
Last - Text (client)
Program - Text
Con Hours - Number
Con Date - Date/Time
From - Date/Time (this is the start date of week for Notes)
To - Date/Time (this is the end date of week)
Hours - Number
ID - AutoNumber
Dups OK - Text
Note - Text
Sample Date:
PPE Date - 05/23/2008
Advocate Last - Smith
Advocate First - John
Emp # - 012345
Pay Rate - 14.00
First - Julie
Last - Adams
Program - PAL
Con Hours - 25
Con Date - 07/01/08
From - 05/31/08
To - 06/06/08
Hours - 25
ID - AutoNumber
Dups OK - "Blank"
Note - Worked 25 this week.
-----
Response by Karl Dewey:
I used table name JWeaver (I changed this to Wrap Payroll) and first query
named JWeaver_1 (Changed to Wrap Payroll_1). These give you the record that
is more than 7 days from the previous one.
SELECT Q.[Advocate Last], Q.[Advocate First], Q.From, (SELECT COUNT(*) FROM
Wrap Payroll Q1
WHERE Q1.[Advocate Last] = Q.[Advocate Last]
AND Q1.[Advocate First] = Q.[Advocate First]
AND Q1.From < Q.From)+1 AS Rank
FROM Wrap Payroll AS Q
ORDER BY Q.[Advocate Last], Q.[Advocate First], Q.From;
SELECT Wrap Payroll_1.Rank, Wrap Payroll.*
FROM (Wrap Payroll INNER JOIN Wrap Payroll ON (Wrap Payroll.[Advocate First]
=
Wrap Payroll.[Advocate First]) AND (Wrap Payroll.[Advocate Last] =
Wrap Payroll.[Advocate Last])) INNER JOIN Wrap Payroll AS Wrap Payroll_1 ON
(Wrap Payroll.From = Wrap Payroll_1.From) AND (Wrap Payroll.[Advocate First]
=
Wrap Payroll_1.[Advocate First]) AND (Wrap Payroll.[Advocate Last] =
Wrap Payroll_1.[Advocate Last])
WHERE (((Wrap Payroll_1.Rank)=[Wrap Payroll].[Rank]+1) AND
((DateDiff("d",[Wrap Payroll].[From],[Wrap Payroll_1].[From]))>7));
This will give you the records that is followed by more than 7 days ---
SELECT Wrap Payroll_1.Rank, Wrap Payroll.*
FROM (Wrap Payroll INNER JOIN Wrap Payroll ON (Wrap Payroll.From = Wrap
Payroll.From) AND
(Wrap Payroll.[Advocate First] = Wrap Payroll.[Advocate First]) AND
(Wrap Payroll.[Advocate Last] = Wrap Payroll.[Advocate Last])) INNER JOIN
Wrap Payroll
AS Wrap Payroll_1 ON (Wrap Payroll.[Advocate First] = Wrap
Payroll_1.[Advocate First])
AND (Wrap Payroll.[Advocate Last] = Wrap Payroll_1.[Advocate Last])
WHERE (((Wrap Payroll_1.Rank)=[Wrap Payroll].[Rank]+1) AND
((DateDiff("d",[Wrap Payroll].[From],[Wrap Payroll_1].[From]))>7));
Any help is greatly appreciated!!!