Forum Discussion
AndrewButters
May 18, 2021Copper Contributor
Display Auto-Populated Resource Field on Task Sheet
I have a list of resources and associated info (resource name, group, etc...). Two of these fields are customer resource fields (Text1, Text2). When I am on my Task Sheet I select a resource and the ...
- May 19, 2021
The macros in the Wiki article are structured to transfer assignment data to task data or vice versa. It sounds like like what you want to do is to transfer resource data to task data. That is easy enough as long as there is only one assigned resource per task but it presents a dilemma if more than one resource is assigned to a given task, as is often the case.
However, if you do have a single resource assigned to each task, then this code should give you what you want.
Sub ResToTsk()
Dim t As Task
For Each t In ActiveProject.Tasks
If Not t Is Nothing Then
If t.Assignments.Count > 0 Then
t.Text1 = ActiveProject.Resources(t.Assignments(1).ResourceID).Text1
t.Text2 = ActiveProject.Resources(t.Assignments(1).ResourceID).Text2
End If
End If
Next t
End Sub
If you have more than one resource assigned per task, then you need to determine which resource's custom field is transferred to the task custom field.
John
AndrewButters
May 20, 2021Copper Contributor
John-project Alas, I am getting an error.
Run-time error '1101':
The argument value is not valid.
When debugging it highlights this line:
t.Text1 = ActiveProject.Resources(t.Assignments(1).ResourceID).Text1
John-project
May 20, 2021Silver Contributor
Check my posted code again. I added a couple of lines to account for tasks that have no resources assigned.
John
John