PRJ4: Add Method Returns Wrong Resource Assignment UniqueID

Last reviewed: November 24, 1997
Article ID: Q137167
The information in this article applies to:
  • Microsoft Project for Windows, version 4.0
  • Microsoft Project for Windows 95, version 4.1
  • Microsoft Project for Macintosh, version 4.0

SYMPTOMS

In Microsoft Project, when you run a macro to return the UniqueID property of a resource assignment (Assignments collection), an incorrect number may be returned.

CAUSE

This problem occurs if you use the Add method to return the unique ID for a resource assignment if the resource has been assigned to the task multiple times. For example, if you run the following macro

   Sub Macro1()
      Dim X as Object
      ' Add resource to task and set variable X equal to first
      ' resource assignment
      Set X = Projects(1).Tasks(1).Assignments.Add(1,1)
      ' Display unique ID for first resource assignment
      MsgBox X.UniqueID
      ' Add resource to task a second time and set
      ' variable X equal to second resource assignment
      Set X = Projects(1).Tasks(1).Assignments.Add(1,1)
      ' Display unique ID for second resource assignment
      MsgBox X.UniqueID
   End Sub

the second dialog box that should return the unique ID of the second resource assignment (2) displays the value 1 instead.

The Add method returns the first assignment for the task when you assign a resource multiple times.

WORKAROUNDS

To work around this problem, use the specific Assignments object to return the UniqueID property as in the following example:

   ' Assignments(2) is the second resource assignment
   ' for the first task
   MsgBox Projects(1).Tasks(1).Assignments(2).UniqueID

Microsoft provides examples of Visual Basic procedures for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This Visual Basic procedure is provided 'as is' and Microsoft does not guarantee that it can be used in all situations. Microsoft does not support modifications of this procedure to suit customer requirements for a particular purpose.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

REFERENCES

For more information about the "Add Method," choose the Search button in the Visual Basic Reference and type

   add

choose the Show Topics button, select the topic, and choose Go To.


Additional query words: 4.00 ole automation
Keywords : kbcode kbprg
Version : 4.0 4.1
Platform : MACINTOSH WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.