Change Event in wrong row

N

NevilleT

I am trying to update the percent complete on a task when a custom field
(Number2) changes. A custom field (Number3) contains a formula that
calculates the perecent complete using Number2.

I am using Project 2000. The main code is:

Private Sub Project_Change(ByVal pj As Project)
Dim lngCalcPercent As Long
SelectTaskField row:=0, Column:="Number3"
lngCalcPercent = ActiveCell.Task.Number3

SelectTaskField row:=0, Column:="PercentComplete"

If ActiveCell.Task.PercentComplete <> lngCalcPercent Then
ActiveCell.Task.PercentComplete = lngCalcPercent
End If

End Sub

The problem is that if the user hits the enter or down arrow key after
entry, the change event is triggered in the wrong row. It is in the row
below the task that was changed. Is there any way to replace the line:

SelectTaskField row:=0, Column:="Number3"

With a command that identifies the row where the change took place, or
alternatively fire the event prior to the focus moving to another task.
 
B

Brian K - Project MVP

NevilleT wrote:

The problem is that if the user hits the enter or down arrow key after
entry, the change event is triggered in the wrong row. It is in the row
below the task that was changed. Is there any way to replace the line:

SelectTaskField row:=0, Column:="Number3"

With a command that identifies the row where the change took place, or
alternatively fire the event prior to the focus moving to another task.

It might help to use an application level event for this. Using this event
you would not need to depend on the row for your hook into the task that
changed. The event passes you the ID of the changed task and lets you do
anything you like to it. Here is an article that explains the ins and outs:

Monitoring task changes in Project 2000
<http://techrepublic.com.com/5100-6313_11-5032122-1-1.html>

It was written for 2000 but it should still work. The event did not change
any in the last two versions.
 
B

Brian K - Project MVP

NevilleT said:
Thanks Brian. That worked - eventually. Had to do a bit of work but it
got
me started. Found another good article at
http://masamiki.com/project/project_open.htm


Yes, Jacks stuff is all very good. Im glad it got you going. you could
have done it the way you were going but it would have been a lot of work,
and now you know how to use application events which is 40 or 50% cooler
than using the other events. :)
 

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