Oops! ProjectBeforeTaskChange fired

R

Robert X

Hello,

I'm trying to use the ProjectBeforeTaskChange event: when the
pjTaskDuration1 field is changed by the user, I need to change the value of
pjTaskDuration2. But when this second change happens, the
ProjectBeforeTaskChange event is fired a second time.
How can I stop the ProjectBeforeTaskChange so that it runs only once.
Thanks in advance

Robert
 
J

Jan De Messemaeker

Hi
Start the handling with
If field = pjtaskduration1 then
....

and end with

end if

It will fire a second time but nothing will happen.
HTH
 
R

Robert X

Hi Jan,
I already have a test like:
If field = pjtaskduration1 then
....and another one:
If field = pjtaskduration2 then

....but while the event is fired on the second time, that's the "If field =
pjtaskduration2 then" test which is solicited and which is doing some bad
work. how could I prevent this?
(NB : the user is able to change both pjtaskduration1 and pjtaskduration2)
Thanks for your help.

Robert
 
J

Jan De Messemaeker

Hi,

One solution I use for this is (maybe too) radical but it works.
When duration1 is changed, in the event module I set a value directly into
global.mpt which does not fire any event and can be tested when duration2
changes:

vbe.vbprojects(1).vbcomponents(1).properties("Number1")=1

And in the duration2 handling
if vbe.vbprojects(1).vbcomponents(1).properties("Number1")=1 then

Of course I end the duration1 handling by
vbe.vbprojects(1).vbcomponents(1).properties("Number1")=0

Hope this helps
 
J

John

Jan De Messemaeker said:
Hi,

One solution I use for this is (maybe too) radical but it works.
When duration1 is changed, in the event module I set a value directly into
global.mpt which does not fire any event and can be tested when duration2
changes:

vbe.vbprojects(1).vbcomponents(1).properties("Number1")=1

And in the duration2 handling
if vbe.vbprojects(1).vbcomponents(1).properties("Number1")=1 then

Of course I end the duration1 handling by
vbe.vbprojects(1).vbcomponents(1).properties("Number1")=0

Hope this helps
Jan,
I'd like to learn more about the object model of the VBE. I can type out
a line of code and IntelliSense will offer various properties at each
level but I'd like to find a reference that has information about each
property. For example, I can find the vbproject Property in the object
browser, but I can't find anything about "vbcomponents". What is a good
source for more detailed information on the VBE?

John
 
J

Jan De Messemaeker

Hi John,

I have to admit that I learned this by trying, trying, and once more trying.
I still don't know the meaning of most of these properties but some I know
(and I learned to use frequently)
And I'd like to know more...
 
J

John

Jan De Messemaeker said:
Hi John,

I have to admit that I learned this by trying, trying, and once more trying.
I still don't know the meaning of most of these properties but some I know
(and I learned to use frequently)
And I'd like to know more...

Jan,
I understand. Unfortunately a lot of the little tricks I learned the
same way - by trial and error or blind stupid luck. Anyway, thanks for
the reply.

John
 
R

Robert X

Jan,

Big problem: The following setting :
vbe.vbprojects(1).vbcomponents(1).properties("Number1")=1
fires once more the ProjectBeforeTaskChange !!! So I got an infinite loop.
What could be the solution?
PS : what is this "Number1" field (Task? Resource? Project?) where is it ? I
noticed that in the Organizer dialog box, we can't copy custom fields
from/to the Global.mpt any more.

Robert
 
J

Jan De Messemaeker

Hi,

It's a matter of sequencing the If statements.
Start checking for duration1 as field
Then check for the number1=1 (which means you already were here)
if not set number1 to 1
The event fires but since the field is not duration1 (it will be number1)
nothing is handled
Now every time the event is fired the logic will know that all started with
a duration1 change
At the end of the duration1 handling reset number1 to 0
Once again the event fires but once again the fiield is number1 so if you
exclude that within your if statements nothong will happen and you will not
have a loop.

This text1 is a property of the project summary task of global.mpt (know of
not other way to access it) so indeed it fires task change.
 

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