Cannot set the Task.ActualCost and Task.ActualWork ?

E

Eugene Rokhlin

Hi All,

I get an error 1101 'The argument value is not valid' trying to set the
ActualCost and ActualWork properties of the task

The code is as simple as that:

Set objTask = m_objActiveProj.Tasks.Add

With objTask
.Name = rs.Fields("Description")
.WBS = rs.Fields("WBS")
.ActualStart = Format(rs.Fields("dtSchedStartDate"), "dd mmm
yyyy")
.ActualFinish = Format(rs.Fields("dtSchedEndDate"), "dd mmm
yyyy")
.ActualCost = rs.Fields("mActualCost")
.ActualWork = rs.Fields("nActualHours")
End With

Other properties are set successfully.
I even tried to set ActualCost and ActualWork to some integer or variant
constants, but still get the same error.

What should I do?

Thanks.
 
M

Mike Glen

Hi Eugene ,

On the msnews.microsoft.com server, try the microsoft.public.project.vba
newsgroup as you are more likely to get an answer there.

FAQs, companion products and other useful Project information can be seen at
this web address: http://www.mvps.org/project/

Hope this helps - please let us know how you get on:)

Mike Glen
MS Project MVP
 
J

Jan De Messemaeker

Hi Eugene,

You may have the option on
"Actual Costs are always Calculated by Microsoft project"

in Toolss, Option, Calculation.
HTH
--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
Project Management Consultancy
Prom+ade BVBA
32-495-300 620
 
E

Eugene Rokhlin

Thanks for the links, Mike.

OK, this one was solved.
I have no idea why, but the following change did help:

This
===============
Set objTask = m_objActiveProj.Tasks.Add

With objTask
.ActualCost = rs.Fields("mActualCost")
.ActualWork = rs.Fields("nActualHours")
End With
================
Became this
================
Dim varActualCost As Variant
Dim varActualWork As Variant

If IsNull(rs.Fields("mActualCost")) Then
varActualCost = 0
Else
varActualCost = rs.Fields("mActualCost")
End If

If IsNull(rs.Fields("nActualHours")) Then
varActualWork = 0
Else
varActualWork = rs.Fields("nActualHours")
End If

Set objTask = m_objActiveProj.Tasks.Add

With objTask
.ActualCost = varActualCost
.ActualWork = varActualWork
End With
================
(It were not the null values that were to blame, I just thought that an
extra check would be good.)
 

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