Project 2007 Resource Assignment Bug?

B

BillB

Just so I know it's not me, could someone out there try the following?

Create a new project in MSP 2007 Pro. One work resource assigned to one task
(one unit).

Create a module in the project and paste in the following code:

'-----------------------------------------------

Function tfl(b As Boolean) As Integer
tfl = IIf(b, 1, 0)
End Function

Sub WriteVals()
Dim t As Task, a As Assignment, i
For Each t In ActiveProject.Tasks
Debug.Print t.ID
'For i = 0 To t.Assignments.Count - 1
'Set a = t.Assignments(i + 1) '
For Each a In t.Assignments
With a
Debug.Print .ResourceName
Debug.Print "Names" & vbTab & "1" & vbTab & "2" & vbTab &
"3" & vbTab & "4" & vbTab & "5" & vbTab & "6" & vbTab & "7" & vbTab & "8" &
vbTab & "9" & vbTab & "10" & vbTab & vbTab & "11" & vbTab & "12" & vbTab &
"13" & vbTab & "14" & vbTab & "15" & vbTab & "16" & vbTab & "17" & vbTab &
"18" & vbTab & "19" & vbTab & "20"
Debug.Print "Flags" & vbTab & tfl(.Flag1) & vbTab &
tfl(.Flag2) & vbTab & tfl(.Flag3) & vbTab & tfl(.Flag4) & vbTab &
tfl(.Flag5) & vbTab & tfl(.Flag6) & vbTab & tfl(.Flag7) & vbTab &
tfl(.Flag8) & vbTab & tfl(.Flag9) & vbTab & tfl(.Flag10) & vbTab & vbTab &
tfl(.Flag11) & vbTab & tfl(.Flag12) & vbTab & tfl(.Flag13) & vbTab &
tfl(.Flag14) & vbTab & tfl(.Flag15) & vbTab & tfl(.Flag16) & vbTab &
tfl(.Flag17) & vbTab & tfl(.Flag18) & vbTab & tfl(.Flag19) & vbTab &
tfl(.Flag20)
Debug.Print "Numbers" & vbTab & .Number1 & vbTab & .Number2
& vbTab & .Number3 & vbTab & .Number4 & vbTab & .Number5 & vbTab & .Number6
& vbTab & .Number7 & vbTab & .Number8 & vbTab & .Number9 & vbTab & .Number10
& vbTab & vbTab & .Number11 & vbTab & .Number12 & vbTab & .Number13 & vbTab
& .Number14 & vbTab & .Number15 & vbTab & .Number16 & vbTab & .Number17 &
vbTab & .Number18 & vbTab & .Number19 & vbTab & .Number20
End With
'Next i
Next a
Next t
End Sub

Sub SetVals()
Dim t As Task, a As Assignment
Set t = ActiveProject.Tasks(1)
For Each a In t.Assignments
With a
.Flag1 = True
.Flag2 = True
.Flag3 = True
.Flag4 = True
.Flag5 = True
.Flag6 = True
.Flag7 = True
.Flag8 = True
.Flag9 = True
.Flag10 = True
.Flag11 = True
.Flag12 = True
.Flag13 = True
.Flag14 = True
.Flag15 = True
.Flag16 = True
.Flag17 = True
.Flag18 = True
.Flag19 = True
.Flag20 = True
.Number1 = 1
.Number2 = 1
.Number3 = 1
.Number4 = 1
.Number5 = 1
.Number6 = 1
.Number7 = 1
.Number8 = 1
.Number9 = 1
.Number10 = 1
.Number11 = 1
.Number12 = 1
.Number13 = 1
.Number14 = 1
.Number15 = 1
.Number16 = 1
.Number17 = 1
.Number18 = 1
.Number19 = 1
.Number20 = 1

End With
Next a
End Sub

'------------------------------------------

Run the SetVals sub to set number and flag fields in the assignment.
Save the project in 2003 format and reopen.
Then run the WriteVals sub twice, once with the indexed for loop and once
with the for ... next loop.
I get different values depending on which loop I use. The indexed loop gives
invalid results even with a single resource.

Can anyone else reproduce this? And if it is a problem, can I be sure that
the for each loop will pass through the assignments in the same order every
time?

Thanks,

Bill B
 
J

Jim Aksel

I can reproduce this in P2007 Pro, it is not necessary to change to P2003
format. I can reproduce this behavior in P2007 Pro using either format file.
What I get is Flags1 & 2 set to 1 when using the indexed loop, Flags 3 and
later set to 0. Numbers all set to 1. Using the Assignments Loop, everybody
sets at 1 both numbers and flags

Taking the file down to P2003 Pro, I cannot reproduce the error-- no matter
what I do, it shows 1 for both Flags and Numbers.

Now we get to go figure out why...

--
If this post was helpful, please consider rating it.

Jim
It''s software; it''s not allowed to win.

Visit http://project.mvps.org/ for FAQs and more information
about Microsoft Project
 
J

Jim Aksel

I don't know on the MS Access thing, same with save to HTML.
They are wanting 3rd party people to pick this up with XML which would
eliminate the need for both Access & HTML. The only problem is that doing
down the XML route is a steeper learning curve than Access. All in all
though, I think it is a good thing to allow the flexibility XML will
ultimately offer.

Go write up the "bug" you found on Connect and let's see if anyone else can
validiate.
--
If this post was helpful, please consider rating it.

Jim
It''s software; it''s not allowed to win.

Visit http://project.mvps.org/ for FAQs and more information
about Microsoft Project
 
B

BillB

I got the same results as you at one point, though I've seen other results
as well. It's really a pain for me because I use those fields a lot. I
rewrote some of my code to loop using for each but using for each to set the
values returns weird results when you get the values back with for each.
This never happened in any other version of MSP. I posted this on the
Microsoft Connect thing, so we'll see if anyone bites.

BTW, any idea why MS dropped the Access database Save As option for 2007?
That one's killing me too.

Bill B
 
B

BillB

Well, I sent it in to Connect and no one's looked at it yet. Then I was told
(by my unhappy boss) to call it in to MS, spent 2 hours on the phone with a
MS support guy who told me they don't support VBA/object model problems,
would I like a list of partners, and maybe we can get you back your $49 but
don't count on it.

Meanwhile, my boss is fuming that I'm not getting anything done. Do you know
any phone number to report a legitimate (at least I think so) bug in the MSP
2007 OM?
 
J

Jim Aksel

Sorry, I don't have any numbers for you. We're all just volunteers out here
in cyberspace with no real "in" to that type of thing. We don't work for MS.

Perhaps you could try a different approach. Although you can identify the
problem using VBA, the underlying problem my be entirely different. What you
have is the method is not producing the same results between the versions.
Maybe if you were to write it up differently it could get some attention.

I can see their point -- it is up to developers to test their code. You
have identified an issue, as well as a work around. This is normal procedure
when the methods don't behave like you want them to.... you have to find
another way to solve the problem (even if it means recoding your legacy work).

It looks like you need to find out (perhaps from the Object Browser) what
the specified behavior is for Tasks and Assignments. Clearly
t.Assignment.Count is not giving you the same value for "i" as are expecting.
So, check what the Object Browser documentation is telling you for the
Task.Assignment.Count object .... if the result you get in your program
differs from the "Specified Behavior" then write it up that way and see if
anyone bites.

To be honest, when I read your post several days ago, my initial reaction
was that there was a logical flaw as to our mutual understanding of how
Assignments and Tasks work. I didn;t have time to study it closely (and I
still don't), but I think the answer lays in there somewhere.

So, I took the lazy way out and just answered your question - "Can you
duplicate this..." and I just answered it "yes" .... easy way out on my end.

Anway, it appears that t.Assignments.Count is not giving you what you
expect. So, the answer is one of two things (1) Education as to what
Assignment.Count really provides, or, (2) Assignment.Count is producing
eroneous results compared to what its "spec" says. It is troubling that the
results vary from P2003 to P2007.

You may also want to go into the object browser on ActiveProject.Tasks(x)
and see if that gets you anything. There's a reason for the behavior, need
to understand it, and then compare it to what it is supposed to do.

Maybe someone else will chime in.
--
If this post was helpful, please consider rating it.

Jim
It''s software; it''s not allowed to win.

Visit http://project.mvps.org/ for FAQs and more information
about Microsoft Project
 
J

Jim Aksel

Rating? Berating? (hee hee). To do that you should see a question at the
bottom of the window that asks if my post was helpful, selecting "yes" or
"no" is all you do.
Sometimes the question is "Did this answer the question".

I access this site through microsoft.public.project.developer although I
think there is more than one road that leads to "Rome":
http://www.microsoft.com/office/com...r=US&mid=9e1e1376-d7db-4834-82ad-4fee6ab6ea0e


I do .NET programming in VB for Project. I will give it a try as time
allows and post back. I am just so swamped over here now that pulling up
Visual Studio is going to be a challenge.

Jim
 
B

BillB

Thanks for the response.

I don't see the problem as being with Assignment.count, since the count
returned is correct (the problem happens with 1 task with 1 assignment). I
think the problem is that different chunks of memory are being returned for
the same object depending on whether you access it through the index (for i
= 1 to) method or the for each method. One of the chunks of memory has the
correct values, you can determine this by looking at the object through the
watch window in the debugger. The other chunk doesn't. I tried the same test
using the Startn, Durationn and Textn fields and the valus are the same no
matter how you loop through. Only the Number and Flag fields cause a
problem. What would be interesting is to see if a .Net implementation came
up with the same result. I program in VB6 and that shows the same result as
VBA.

There's no logical flaw that I can see. It's as if I wrote a number on the
wall and if you looked at it from the right side it said "1" and if you
looked at it from the left side it said "0". And I don't see that I've
developed a work-around since the results are unreliable at best. If this
problem happened with the Flagn fields on task record, developers would go
nuts.

I'd rate you if I knew how.

Bill
 
Top