Help: Macro to Update "Last Updated" date field if any tasks changes

B

Bill Marshall

Good day!

I need help automatically updating a field called "Last Updated
(Date1) with today's date if a task changes. Here's the business need:
need to be able to track when users go in and update the tasks they own
If you go in and update any field pertaining to a task you own, the
this "Last Updated" field should get populated with the date you mad
the change (if not today).

I was tooling around MS Project VBA online help and learned more abou
App_ProjectBeforeTaskChange, so I think I need to use that. Other onlin
research seems to confirm this. I'm completely new at VBA, and while
try to amend what I find to suit my own purposes, I can't veer too fa
off the beaten path.

Here's what I came up with, which is sadly neither elegant no
functional:


Code
-------------------
private sub app_projectbeforetaskchange(byval tsk as task,
byval field as pjfield, byval newval as variant, cancel as boolean)

dim text1 as long
dim text2 as long
dim text3 as long
dim text4 as long
dim text5 as long
dim text6 as long
dim text7 as long
dim text8 as long
dim text9 as long
dim text10 as long
dim text11 as long
dim text12 as long
dim text13 as long
dim text14 as long
dim text15 as long
dim text16 as long
dim text17 as long
dim text18 as long
dim text19 as long
dim text20 as long
dim text21 as long
dim text21 as long
dim text22 as long
dim text23 as long
dim text24 as long
dim text25 as long
dim text30 as long
dim number1 as long
dim number2 as long
dim number3 as long
dim number4 as long
dim number5 as long

if pjdate1 = date() then exit sub
else if ((field = pjtext1 and text1 <> tsk.text1) or (field = pjtext2 and text2 <> tsk.text2 ) or _
(field = pjtext3 and text3 <> tsk.) or (field = pjtext4 and text4 <> tsk.) or _
(field = pjtext5 and text5 <> tsk.) or (field = pjtext6 and text6 <> tsk.) or _
(field = pjtext7 and text7 <> tsk.) or (field = pjtext8 and text8 <> tsk.) or _
(field = pjtext9 and text9 <> tsk.) or (field = pjtext10 and text10 <> tsk.) or _
(field = pjtext11 and text11 <> tsk.) or (field = pjtext12 and text12 <> tsk.) or _
(field = pjtext13 and text13 <> tsk.) or (field = pjtext14 and text14 <> tsk.) or _
(field = pjtext15 and text15 <> tsk.) or (field = pjtext16 and text16 <> tsk.) or _
(field = pjtext17 and text17 <> tsk.) or (field = pjtext18 and text18 <> tsk.) or _
(field = pjtext19 and text19 <> tsk.) or (field = pjtext20 and text20 <> tsk.) or _
(field = pjtext21 and text21 <> tsk.) or (field = pjtext21 and text21 <> tsk.) or _
(field = pjtext22 and text22 <> tsk.) or (field = pjtext23 and text23 <> tsk.) or _
(field = pjtext24 and text24 <> tsk.) or (field = pjtext25 and text25 <> tsk.) or _
(field = pjtext30 and text30 <> tsk.) or (field = pjnumber1 and number1 <> tsk.) or _
(field = pjnumber2 and number2 <> tsk.) or (field = pjnumber3 and number3 <> tsk.) or _
(field = pjnumber4 and number4 <> tsk.) or (field = pjnumber5 and number4 <> tsk.))
tsk.date1 = date()
end if
end if
end su
-------------------


I greatly appreciate any help you can provide me.

- Bil
 
M

Mike Glen

Hi Bill,

Try posting on the microsoft.public.project.developer newsgroup (forum).
Please see FAQ Item: 24. Project Newsgroups. FAQs, companion products and
other useful Project information can be seen at this web address:
http://project.mvps.org/faqs.htm

Mike Glen
Project MVP
 

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