T
Trexner
Hello all,
I have a table in a database named "tm_tasks" that contains records of tasks
to be carried out on a case. The end user enters the tasks from a form which
includes a future date by which the task must be completed. The date is
stored in the column "CASE_DUE_DATE". The structure of the table is:
TASK_ID (autonumber field)
CLIENT_ID (link back to another table holding the client specific data)
CASE_ID (link back to another table holding the case specific data)
CASE_DATE_ENTERED (the date the task is created - defaults to "Date() )
CASE_DAYS_OUT (the number of days before task must be completed)
CASE_DUE_DATE (calculated as a DateAdd of the two above)
CASE_TASK (memo field of what the end user must to do complete the task)
CASE_TASK_COMPLETED (yes/no field to be ticked when task is completed)
The tm_tasks table will have multiple rows for each case as the end user
will put in several tasks with future dates at one time. Additionally, as
the tasks are completed and the user ticks the completed task box, the old
tasks will remain until the case is completely closed and the rows are moved
to an archive at a later time.
I've had no problem building a task report showing all tasks, sorted by the
task closest to today's date from which the end user can prioritize their
day/week/month schedule.
What I'm trying to do is build a query that will show ONLY one task per open
case (CASE_ID). I need it to check for future tasks, and if there are future
tasks, select the row that has the task that is closest to today (aka...the
next task that needs to be completed for that case). AND, if there are no
future tasks, it needs to select the row of the most recent past task. The
result will be a status report that shows the most current task on the case
(and only one task), the next future if there is one, or the most recent past
if no future tasks exist.
Once I get the query to select only one row for each case by the nearest
date, future or past, I will then add in a fair number of joins to include
additional details from other tables But first I have to get it to select
the correct row, and only one row, for each CASE_ID based on the nearest
date, future if available, past if not.
Thanks in advance!
I have a table in a database named "tm_tasks" that contains records of tasks
to be carried out on a case. The end user enters the tasks from a form which
includes a future date by which the task must be completed. The date is
stored in the column "CASE_DUE_DATE". The structure of the table is:
TASK_ID (autonumber field)
CLIENT_ID (link back to another table holding the client specific data)
CASE_ID (link back to another table holding the case specific data)
CASE_DATE_ENTERED (the date the task is created - defaults to "Date() )
CASE_DAYS_OUT (the number of days before task must be completed)
CASE_DUE_DATE (calculated as a DateAdd of the two above)
CASE_TASK (memo field of what the end user must to do complete the task)
CASE_TASK_COMPLETED (yes/no field to be ticked when task is completed)
The tm_tasks table will have multiple rows for each case as the end user
will put in several tasks with future dates at one time. Additionally, as
the tasks are completed and the user ticks the completed task box, the old
tasks will remain until the case is completely closed and the rows are moved
to an archive at a later time.
I've had no problem building a task report showing all tasks, sorted by the
task closest to today's date from which the end user can prioritize their
day/week/month schedule.
What I'm trying to do is build a query that will show ONLY one task per open
case (CASE_ID). I need it to check for future tasks, and if there are future
tasks, select the row that has the task that is closest to today (aka...the
next task that needs to be completed for that case). AND, if there are no
future tasks, it needs to select the row of the most recent past task. The
result will be a status report that shows the most current task on the case
(and only one task), the next future if there is one, or the most recent past
if no future tasks exist.
Once I get the query to select only one row for each case by the nearest
date, future or past, I will then add in a fair number of joins to include
additional details from other tables But first I have to get it to select
the correct row, and only one row, for each CASE_ID based on the nearest
date, future if available, past if not.
Thanks in advance!