SOLVED

Display Auto-Populated Resource Field on Task Sheet

Copper Contributor

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 Resource Group field auto-populates. However, I need those other fields from the Resource list in my view as well, and when I try to add them, it only allows me to select Task fields (i.e. not all resource fields are in the list). Is there any way to do this?

8 Replies

@AndrewButters 

Is there a way? Yes, but it requires either manual entry or some VBA. Rather than explaining it all here, I suggest you take a look at the following Wiki article:

https://social.technet.microsoft.com/wiki/contents/articles/32051.ms-project-extra-fields-in-views.a... 

 

John

@John-project Thank you, I will check out the article. I'm no stranger to VBA and really hoping to avoid manual entry since I have hundreds of these things to maintain. 

I got the macro to work but only see the change on the Task Usage View but what I really need is for it to show up when I'm editing from the Task Sheet. I tried removing and re-adding the fields to the Task Sheet but the data only shows up when I am looking at the Task Usage View. Any thoughts?
best response confirmed by AndrewButters (Copper Contributor)
Solution

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

@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

Check my posted code again. I added a couple of lines to account for tasks that have no resources assigned.

John

@John-project It works! Thank you so much, this is going to save me a lot of time and hassle. 

AndrewButters,
You're welcome and thanks for the feedback.
John
1 best response

Accepted Solutions
best response confirmed by AndrewButters (Copper Contributor)
Solution

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

View solution in original post