Cancel changes

R

rama

Hi,

This is what I want to do:

I am changing duration to change task Finish date. I have to validate new
task finsh date with our business policies. If if the new finish date is
allowed I can let the changes go thru. If not I must cancel the changes by
prompting the user.

Problem I am facing:

Once I chnage the duration, task finish date is changing. But, to read new
finish date I have to go to ProjectCalculate event. After I read the value, I
tried to cancel the changes, but I am not able to do it because Cancel is not
available in that event.
How do I overcome this issue. Please help.
 
J

Jack Dahlgren MVP

Rama,

The easiest way to control this sort of thing is not through events.

Build a VBA form.
The form will allow the user to change the duration and will calculate the
expected finish data (current date + remaining duration for example)
Have the form display what the new finish would be, but at the same time, it
can check with the business logic and either prompt the user to pick a
different day or automatically choose the next allowed finish date.
Then the user can click an update button and it will set the duration on the
task.

The big problem is that a change to one task may change other tasks. So you
should probably just make calendar exceptions so that tasks can not finish
on dates prohibited by your policy.

If you can do that, there is no need to do anything different and project
will automatically schedule around the prohibited dates.

-Jack Dahlgren
 
R

rama

Thanks Jack.

Let me give me my project structure.

I have numerous parent tasks with 4 sub tasks in each parent, each sub task
is dependent on its predecessor. When I change sub task's duration Parent's
finish date changes. I would like to trap parent's changed Finish date when
child's duration is changed.
 
J

Jack Dahlgren MVP

Trapping Project events is not a very robust way of doing things.
There are a few conditions where they are not trapped at all.
And if your users have macros turned off then they are of no use.

I personally would not build a solution based on them. Consider using task
calendars instead. It will be much more reliable.

-Jack

rama said:
Thanks Jack.

Let me give me my project structure.

I have numerous parent tasks with 4 sub tasks in each parent, each sub
task
is dependent on its predecessor. When I change sub task's duration
Parent's
finish date changes. I would like to trap parent's changed Finish date
when
child's duration is changed.
 
R

rama

Thanks Jack.

I have one more question:- What event fire when Linking tasks? I want to
restrict the user from linking tasks depending on a business policy. Is
there a way I could do this "ProjectBeforeTaskChange" event, so that I can
cancel the action from happening?
 
J

Jack Dahlgren MVP

Rama,

You could possibly use ProjectBeforeTaskChange as the documentation shows it
should fire on changes to any of the following fields, but I still would
worry about people running with macros disabled, thereby keeping your
solution from doing anything.

pjTaskActualCost pjTaskHyperlinkSubAddress
pjTaskActualDuration pjTaskID
pjTaskActualFinish pjTaskIgnoreResourceCalendar
pjTaskActualOvertimeCost pjTaskIndex
pjTaskActualOvertimeWork pjTaskIndicators
pjTaskActualOvertimeWorkProtected pjTaskIsAssignment
pjTaskActualStart pjTaskLateFinish
pjTaskActualWork pjTaskLateStart
pjTaskActualWorkProtected pjTaskLevelAssignments
pjTaskACWP pjTaskLevelCanSplit
pjTaskAssignmentDelay pjTaskLevelDelay
pjTaskAssignmentUnits pjTaskLinkedFields
pjTaskBaseline1-10Cost pjTaskMarked
pjTaskBaseline1-10Duration pjTaskMilestone
pjTaskBaseline1-10DurationEstimated pjTaskName
pjTaskBaseline1-10Finish pjTaskNotes
pjTaskBaseline1-10Start pjTaskNumber1-20
pjTaskBaseline1-10Work pjTaskObjects
pjTaskBaselineCost pjTaskOutlineCode1-10
pjTaskBaselineDuration pjTaskOutlineLevel
pjTaskBaselineDurationEstimated pjTaskOutlineNumber
pjTaskBaselineFinish pjTaskOverallocated
pjTaskBaselineStart pjTaskOvertimeCost
pjTaskBaselineWork pjTaskOvertimeWork
pjTaskBCWP pjTaskParentTask
pjTaskBCWS pjTaskPercentComplete
pjTaskCalendar pjTaskPercentWorkComplete
pjTaskConfirmed pjTaskPhysicalPercentComplete
pjTaskConstraintDate pjTaskPredecessors
pjTaskConstraintType pjTaskPreleveledFinish
pjTaskContact pjTaskPreleveledStart
pjTaskCost pjTaskPriority
pjTaskCost1-10 pjTaskProject
pjTaskCostRateTable pjTaskRecurring
pjTaskCostVariance pjTaskRegularWork
pjTaskCPI pjTaskRemainingCost
pjTaskCreated pjTaskRemainingDuration
pjTaskCritical pjTaskRemainingOvertimeCost
pjTaskCV pjTaskRemainingOvertimeWork
pjTaskCVPercent pjTaskRemainingWork
pjTaskDate1-10 pjTaskResourceEnterpriseMultiValueCode20-29
pjTaskDeadline pjTaskResourceEnterpriseOutlineCode1-29
pjTaskDelay pjTaskResourceEnterpriseRBS
pjTaskDemandedRequest pjTaskResourceGroup
pjTaskDuration pjTaskResourceInitials
pjTaskDuration1-10 pjTaskResourceNames
pjTaskDuration1-10Estimated pjTaskResourcePhonetics
pjTaskDurationVariance pjTaskResourceType
pjTaskEAC pjTaskResponsePending
pjTaskEarlyFinish pjTaskResume
pjTaskEarlyStart pjTaskResumeNoEarlierThan
pjTaskEarnedValueMethod pjTaskRollup
pjTaskEffortDriven pjTaskSheetNotes
pjTaskEnterpriseCost1-10 pjTaskSPI
pjTaskEnterpriseDate1-30 pjTaskStart
pjTaskEnterpriseDuration1-10 pjTaskStart1-10
pjTaskEnterpriseFlag1-20 pjTaskStartSlack
pjTaskEnterpriseNumber1-40 pjTaskStartVariance
pjTaskEnterpriseOutlineCode1-30 pjTaskStatus
pjTaskEnterpriseProjectCost1-10 pjTaskStatusIndicator
pjTaskEnterpriseProjectDate1-30 pjTaskStop
pjTaskEnterpriseProjectDuration1-10 pjTaskSubproject
pjTaskEnterpriseProjectFlag1-20 pjTaskSubprojectReadOnly
pjTaskEnterpriseProjectNumber1-40 pjTaskSuccessors
pjTaskEnterpriseProjectOutlineCode1-30 pjTaskSummary
pjTaskEnterpriseProjectText1-40 pjTaskSV
pjTaskEnterpriseText1-40 pjTaskSVPercent
pjTaskEstimated pjTaskTCPI
pjTaskExternalTask pjTaskTeamStatusPending
pjTaskFinish pjTaskText1-30
pjTaskFinish1-10 pjTaskTotalSlack
pjTaskFinishSlack pjTaskType
pjTaskFinishVariance pjTaskUniqueID
pjTaskFixedCost pjTaskUniquePredecessors
pjTaskFixedCostAccrual pjTaskUniqueSuccessors
pjTaskFixedDuration pjTaskUpdateNeeded
pjTaskFlag1-20 pjTaskVAC
pjTaskFreeSlack pjTaskWBS
pjTaskGroupBySummary pjTaskWBSPredecessors
pjTaskHideBar pjTaskWBSSuccessors
pjTaskHyperlink pjTaskWork
pjTaskHyperlinkAddress pjTaskWorkContour
pjTaskHyperlinkHref pjTaskWorkVariance
pjTaskHyperlinkScreenTip

Remarks
Project events do not occur when the project is embedded in another document
or application.

The ProjectBeforeTaskChange2 event doesn't occur when timescaled data
changes, when constraint data in the Task Details Form changes, when a task
is split by manipulating its task bar on the Gantt Chart, when changes are
made to outline level or outline number, when a baseline is saved, when a
baseline is cleared, when an entire task row is pasted, during resource pool
operations, when inserting or removing a subproject, or when changes have
been made using a custom form.


rama said:
Thanks Jack.

I have one more question:- What event fire when Linking tasks? I want to
restrict the user from linking tasks depending on a business policy. Is
there a way I could do this "ProjectBeforeTaskChange" event, so that I can
cancel the action from happening?
 
R

rama

Thanks for quick reply Jack.

This is for an internal user and I can educate them to turn on macros.

I put a break point in "ProjectBeforeTaskChange" and linked 2 tasks. The
control is going to ProjectCalculate straight away [I cannot cancel here
because there is nno cancel here], without first going to
ProjectBeforeTaskChange.
 
J

Jack Dahlgren MVP

Rama,

I don't know what you can do about this. I continue to caution you against
use of events as they do not always work.

-Jack

rama said:
Thanks for quick reply Jack.

This is for an internal user and I can educate them to turn on macros.

I put a break point in "ProjectBeforeTaskChange" and linked 2 tasks. The
control is going to ProjectCalculate straight away [I cannot cancel here
because there is nno cancel here], without first going to
ProjectBeforeTaskChange.

--
Rama


Jack Dahlgren MVP said:
Rama,

You could possibly use ProjectBeforeTaskChange as the documentation shows
it
should fire on changes to any of the following fields, but I still would
worry about people running with macros disabled, thereby keeping your
solution from doing anything.

pjTaskActualCost pjTaskHyperlinkSubAddress
pjTaskActualDuration pjTaskID
pjTaskActualFinish pjTaskIgnoreResourceCalendar
pjTaskActualOvertimeCost pjTaskIndex
pjTaskActualOvertimeWork pjTaskIndicators
pjTaskActualOvertimeWorkProtected pjTaskIsAssignment
pjTaskActualStart pjTaskLateFinish
pjTaskActualWork pjTaskLateStart
pjTaskActualWorkProtected pjTaskLevelAssignments
pjTaskACWP pjTaskLevelCanSplit
pjTaskAssignmentDelay pjTaskLevelDelay
pjTaskAssignmentUnits pjTaskLinkedFields
pjTaskBaseline1-10Cost pjTaskMarked
pjTaskBaseline1-10Duration pjTaskMilestone
pjTaskBaseline1-10DurationEstimated pjTaskName
pjTaskBaseline1-10Finish pjTaskNotes
pjTaskBaseline1-10Start pjTaskNumber1-20
pjTaskBaseline1-10Work pjTaskObjects
pjTaskBaselineCost pjTaskOutlineCode1-10
pjTaskBaselineDuration pjTaskOutlineLevel
pjTaskBaselineDurationEstimated pjTaskOutlineNumber
pjTaskBaselineFinish pjTaskOverallocated
pjTaskBaselineStart pjTaskOvertimeCost
pjTaskBaselineWork pjTaskOvertimeWork
pjTaskBCWP pjTaskParentTask
pjTaskBCWS pjTaskPercentComplete
pjTaskCalendar pjTaskPercentWorkComplete
pjTaskConfirmed pjTaskPhysicalPercentComplete
pjTaskConstraintDate pjTaskPredecessors
pjTaskConstraintType pjTaskPreleveledFinish
pjTaskContact pjTaskPreleveledStart
pjTaskCost pjTaskPriority
pjTaskCost1-10 pjTaskProject
pjTaskCostRateTable pjTaskRecurring
pjTaskCostVariance pjTaskRegularWork
pjTaskCPI pjTaskRemainingCost
pjTaskCreated pjTaskRemainingDuration
pjTaskCritical pjTaskRemainingOvertimeCost
pjTaskCV pjTaskRemainingOvertimeWork
pjTaskCVPercent pjTaskRemainingWork
pjTaskDate1-10 pjTaskResourceEnterpriseMultiValueCode20-29
pjTaskDeadline pjTaskResourceEnterpriseOutlineCode1-29
pjTaskDelay pjTaskResourceEnterpriseRBS
pjTaskDemandedRequest pjTaskResourceGroup
pjTaskDuration pjTaskResourceInitials
pjTaskDuration1-10 pjTaskResourceNames
pjTaskDuration1-10Estimated pjTaskResourcePhonetics
pjTaskDurationVariance pjTaskResourceType
pjTaskEAC pjTaskResponsePending
pjTaskEarlyFinish pjTaskResume
pjTaskEarlyStart pjTaskResumeNoEarlierThan
pjTaskEarnedValueMethod pjTaskRollup
pjTaskEffortDriven pjTaskSheetNotes
pjTaskEnterpriseCost1-10 pjTaskSPI
pjTaskEnterpriseDate1-30 pjTaskStart
pjTaskEnterpriseDuration1-10 pjTaskStart1-10
pjTaskEnterpriseFlag1-20 pjTaskStartSlack
pjTaskEnterpriseNumber1-40 pjTaskStartVariance
pjTaskEnterpriseOutlineCode1-30 pjTaskStatus
pjTaskEnterpriseProjectCost1-10 pjTaskStatusIndicator
pjTaskEnterpriseProjectDate1-30 pjTaskStop
pjTaskEnterpriseProjectDuration1-10 pjTaskSubproject
pjTaskEnterpriseProjectFlag1-20 pjTaskSubprojectReadOnly
pjTaskEnterpriseProjectNumber1-40 pjTaskSuccessors
pjTaskEnterpriseProjectOutlineCode1-30 pjTaskSummary
pjTaskEnterpriseProjectText1-40 pjTaskSV
pjTaskEnterpriseText1-40 pjTaskSVPercent
pjTaskEstimated pjTaskTCPI
pjTaskExternalTask pjTaskTeamStatusPending
pjTaskFinish pjTaskText1-30
pjTaskFinish1-10 pjTaskTotalSlack
pjTaskFinishSlack pjTaskType
pjTaskFinishVariance pjTaskUniqueID
pjTaskFixedCost pjTaskUniquePredecessors
pjTaskFixedCostAccrual pjTaskUniqueSuccessors
pjTaskFixedDuration pjTaskUpdateNeeded
pjTaskFlag1-20 pjTaskVAC
pjTaskFreeSlack pjTaskWBS
pjTaskGroupBySummary pjTaskWBSPredecessors
pjTaskHideBar pjTaskWBSSuccessors
pjTaskHyperlink pjTaskWork
pjTaskHyperlinkAddress pjTaskWorkContour
pjTaskHyperlinkHref pjTaskWorkVariance
pjTaskHyperlinkScreenTip

Remarks
Project events do not occur when the project is embedded in another
document
or application.

The ProjectBeforeTaskChange2 event doesn't occur when timescaled data
changes, when constraint data in the Task Details Form changes, when a
task
is split by manipulating its task bar on the Gantt Chart, when changes
are
made to outline level or outline number, when a baseline is saved, when a
baseline is cleared, when an entire task row is pasted, during resource
pool
operations, when inserting or removing a subproject, or when changes have
been made using a custom form.
 

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