outlineparent

J

Jose X Perez

hi everyone
I am using project professional 2007, and I have a macro that does some
calculations depending the outline level
this is the code

Private Sub App_ProjectBeforeTaskChange(ByVal t As Task, ByVal Field As
PjField, ByVal NewVal As Variant, Cancel As Boolean)
MsgBox Field
'If Field = pjTaskName Then
If Field = 188743767 Then
If t.OutlineLevel = 1 Then
't.Number2 = t.Number1 * t.Number3 / 100
t.Number2 = NewVal * t.Number3 / 100
Else
't.Number2 = t.Number1 * t.OutlineParent.Number2 / 100
t.Number2 = NewVal * t.OutlineParent.Number2 / 100
End If
End If
End Sub

Now i try to make it a formula in a custom field
an it goes like this.

IIf([Nivel de esquema]=1,[Número1]*[Número3]/100,[Número1]/100)

first problem, how can i express in the formula t.OutlineParent.Number2
I mind, how can i get the value of a parent task field to use in a
calculation of a custom field.

second problem, if the first cannot be solved.
Wich is the name of the field number1, in order to do not use the number?
i do not want to use
If Field = 188743767 Then


Thanks for your help
Jose X Perez
 
R

Rod Gill

HI,

Unfortunately you can only access data for the current task, so you can't
read data for the outline parent.

For field names and numbers read help for:
application.FieldConstantToFieldName
application.FieldNameToFieldConstant

So your code can be:
If Field = FieldNameToFieldConstant("Number1",pjTask) Then

or

If Field=pjTaskNumber1 Then
--

Rod Gill
Microsoft MVP for Project

Author of the only book on Project VBA, see:
http://www.projectvbabook.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top