C
CLSWL
I don't know the syntax to make this work... everything surrounded by * is
unknown
My aim is for the project status to update based on the status of all the
associated tasks. I have a table with all my projects and their name, point
person, and status.
I actually have 2 more levels of data.
I have a table that links each project to several jobs.
I have a table that links each job to several tasks which have an assigned
person and a status. I want the status of these tasks to determine the
status of the overall project.
Public Function CountStatus()
Dim Count1 As Long 'Counts tasks that are not started
Dim Count2 As Long 'Counts tasks that are in work
Dim Count3 As Long 'Counts tasks that are queued
Dim Count4 As Long 'Counts tasks that are complete
Dim Count5 As Long 'Counts tasks that are cancelled
Dim CountAll As Long 'Counts all tasks of a project
For Each *project* In *table of projects*
Count1 = 0
Count2 = 0
Count3 = 0
Count4 = 0
Count5 = 0
CountAll = 0
For Each *task* In *table of project tasks*
If *task status* = 1 Then
'Count1 = Count1 + 1
ElseIf *task status* = 2 Then Count2 = Count2 + 1
ElseIf *task status* = 3 Then Count3 = Count3 + 1
ElseIf *task status* = 4 Then Count4 = Count4 + 1
ElseIf *task status* = 5 Then Count5 = Count5 + 1
End If
CountAll = CountAll + 1
Next
If CountAll = Count5 Then
*project status* = 5
ElseIf CountAll = Count4 Then *project status*= 4
ElseIf CountAll = Count3 Then *project status*= 3
ElseIf CountAll = Count1 Then *project status*= 1
ElseIf CountAll = Count4 + Count5 Then *project status*= 4
ElseIf CountAll = Count1 + Count3 + Count4 + Count5 Then
*project status*= 3
Else: *project status*= 2
End If
Next
unknown
My aim is for the project status to update based on the status of all the
associated tasks. I have a table with all my projects and their name, point
person, and status.
I actually have 2 more levels of data.
I have a table that links each project to several jobs.
I have a table that links each job to several tasks which have an assigned
person and a status. I want the status of these tasks to determine the
status of the overall project.
Public Function CountStatus()
Dim Count1 As Long 'Counts tasks that are not started
Dim Count2 As Long 'Counts tasks that are in work
Dim Count3 As Long 'Counts tasks that are queued
Dim Count4 As Long 'Counts tasks that are complete
Dim Count5 As Long 'Counts tasks that are cancelled
Dim CountAll As Long 'Counts all tasks of a project
For Each *project* In *table of projects*
Count1 = 0
Count2 = 0
Count3 = 0
Count4 = 0
Count5 = 0
CountAll = 0
For Each *task* In *table of project tasks*
If *task status* = 1 Then
'Count1 = Count1 + 1
ElseIf *task status* = 2 Then Count2 = Count2 + 1
ElseIf *task status* = 3 Then Count3 = Count3 + 1
ElseIf *task status* = 4 Then Count4 = Count4 + 1
ElseIf *task status* = 5 Then Count5 = Count5 + 1
End If
CountAll = CountAll + 1
Next
If CountAll = Count5 Then
*project status* = 5
ElseIf CountAll = Count4 Then *project status*= 4
ElseIf CountAll = Count3 Then *project status*= 3
ElseIf CountAll = Count1 Then *project status*= 1
ElseIf CountAll = Count4 + Count5 Then *project status*= 4
ElseIf CountAll = Count1 + Count3 + Count4 + Count5 Then
*project status*= 3
Else: *project status*= 2
End If
Next