Results 1 to 10 of 10
  1. #1
    Lounger
    Join Date
    Aug 2002
    Location
    Indianapolis, Indiana, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    App_ProjectBeforeResourceChange won't change valu (Project 2002)

    Private Sub App_ProjectBeforeResourceChange(ByVal res As Resource, ByVal Field As PjField, ByVal NewVal As Variant, Cancel As Boolean)

    ActiveProject.Resources(res).Cost = 1
    ActiveProject.Resources(res).OvertimeRate = 1

    End Sub

  2. #2
    Lounger
    Join Date
    Aug 2002
    Location
    Indianapolis, Indiana, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    dang it... the vba code gives me an "object required" error. Why?

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    I know nothing about the Project object model, but since <font color=blue>res</font color=blue> is already declared to be of type resource, shouldn't the syntax be
    <pre> res.Cost = 1
    res.OvertimeRate = 1
    </pre>

    StuartR

  4. #4
    Lounger
    Join Date
    Aug 2002
    Location
    Indianapolis, Indiana, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    You know, I thought the same thing. Unfortunatly it tells me "Object required" which indicates to me that the RES in the arguments is not avialable. BUT WAIT A MINUTE... because if I break in the running and add a watch to the RES object, it is the full resource that I selected INCLUDING the cost fields.

    I just don't see why I can not change them. I have tried the application object, the activeproject object, to no avail.

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    I am, as usual, a little bit confused.

    Have you tried the code
    <font color=blue><pre> res.Cost = 1
    res.OvertimeRate = 1
    </pre>

    </font color=blue>
    or did you use
    <font color=red><pre> ActiveProject.Resources(res).Cost = 1
    ActiveProject.Resources(res).OvertimeRate = 1
    </pre>

    </font color=red>
    I would expect to get this error message if you used res as an index to the Resources collection (as in the <font color=red>red</font color=red> example) but the <font color=blue>blue</font color=blue> one should work fine.

    StuartR

  6. #6
    Lounger
    Join Date
    Aug 2002
    Location
    Indianapolis, Indiana, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    both give errors. Object Required for the blue and invalid argument for the red

  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    That's strange.

    If you set a breakpoint in the de###### can you debug.print res.Cost in the immediate window? Can you change res.Cost in the immediate window?

    I assume that the byVal res as resource is correct? Was this supplied automatically or did you add it?

    StuartR

  8. #8
    Lounger
    Join Date
    Aug 2002
    Location
    Indianapolis, Indiana, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    I did all that... it gives me the same object error when I try to change the cost value

  9. #9
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    Sorry, I'm stuck now. I wonder if it is anything to do with that byVal ref as resource, it doesn't make any sense at all to pass a structure by Value, but Visual Basic does that sometimes and I've never understood it!

    StuartR

  10. #10
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: App_ProjectBeforeResourceChange won't change valu (Project 2002)

    I am not at the office to look at this, however, since you can assign a cost and overtime rate to any resource, you would need to define the particular resource. Is the particular resource you are trying to assign these values to named res? If not, put in the name of the resource.

    HTH
    Regards,

    Gary
    (It's been a while!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •