line
line

Reputation: 11

ms project vba get data from fields

I wanna get data from a field of an exact task and put to another field.

but the problem is the field that I wanna get data from could be every visible field in table. in fact fieldname will choose in userform during the VB.

code is like this: (But It does not work)

UserForm1.Show

Dim F as String

F = UserForm1.ComboBox1.Value              ''''F will be a FieldName

ActiveProject.Tasks.UniqueID(1).Text1 = ActiveProject.Tasks.UniqueID(1).F

It can not find field F that is for example "Task Name" or anyfield. how can I address the field?

Thanks

Upvotes: 1

Views: 2635

Answers (1)

Jon Iles
Jon Iles

Reputation: 2579

You'll need to use a combination of FieldNameToFieldConstant and GetField:

F = UserForm1.ComboBox1.Value
task = ActiveProject.Tasks.UniqueID(1)
task.Text1 = task.GetField(FieldNameToFieldConstant(F))

Upvotes: 1

Related Questions