One Table Approach (Listing only Significant Fields)
Task
TaskID (pk)
ParentTask (fk)
Usage (in Query - for treeview)
SELECT TaskID, ParentTask, 1 As Lvl FROM Task T1
WHERE ParentTask Is Null
UNION ALL
SELECT TaskID, ParentTask, 2 As Lvl FROM Task T2
WHERE EXISTS (SELECT 'X' FROM Task T1
WHERE T1.TaskID=T2.ParentTask
AND T1.ParentTask Is Null)
UNION ALL
SELECT TaskID, ParentTask, 3 As Lvl FROM Task T3
WHERE EXISTS (SELECT 'X' FROM Task T1 Inner Join Task T2
ON T1.TaskID=T2.ParentTask
WHERE T2.TaskID=T3.ParentTask
AND T1.ParentTask Is Null)
UNION ALL
SELECT TaskID, ParentTask, 4 As Lvl FROM Task T4
WHERE EXISTS (SELECT 'X' FROM Task T1 Inner Join (Task T2 Inner Join Task T3
ON T2.TaskID=T3.ParentTask)
ON T1.TaskID=T2.ParentTask
WHERE T3.TaskID=T4.ParentTask
AND T1.ParentTask Is Null)
....
ORDER By Lvl, TaskID
You may have to have a field for the articles (redundant) to build up the
string 1.2.1.4
To ensure uniqueness you'd then have a unique index on
TaskID, Article - where Article is a numeric, this you can build by moving
(part of) the Exists sub-selects into the Main Select at each level
And if you were using Oracle it would be childs play using the 'connect by
prior' construct & Level reserved 'label' <g>
HTH
Pieter
I'm working to develop a planning database for a client, and
essentially the client has an outline with different tasks and
subtasks. For instance, you have task 1 and then sub-tasks 1.1, 1.2,
etc., and to even further degrees, all the way to 1.2.3.4.5.6. In
order to achieve task 1, you must complete 1.1, 1.2, etc. I'm
basically at a loss as to how to get these all designed in access, it
seems like the task number could be the primary key, but how do I set
it up so access knows that 1.2.1 is a subtask of 1.2? Any help is
greatly appreciated. Thanks.
OK, I think if I break it down into SubTasks, so I have Task 1, then
SubTask 2 and SubTask3, which would combine to task 1.2.3. I've
assigned each subtask its own ID number, automatically assigned (an
arbitrary number). The question I have now is that there are up to 6
degrees of tasks, and what's the best way to get it so that if the
fields of Task, SubTask1, Subtask2, etc. are all filled out there's a
text box on a form that calculates it to actually read "1.2.3.4.5.6"?
I tried to just use the regular string with a whole slew of
"IIF(IsNull[SubTask2])..." but it got too complicated with up to 6
subtasks. Thanks.