Audit trail

D

dgmoore

I have a requirement to capture all changes to an mpp file (Prj03) and
populate them to a database in order to maintain an audit trail (this
is to keep track of daily changes to records as part of a metrics
process, not to compare with the baseline, which is strictly controlled
and is changed infrequently).

I have created a VB form to do this: it displays the current content of
selected fields from the current record and provides blank fields into
which new values are entered. Clicking a button labeled 'Update' places
these values in the corresponding Project fields and also appends a
record to an Access database containing the field name, old content,
new content, date of update, and person doing the update.

This works all right, but it's a little cumbersome. Can anybody suggest
a way to detect and capture changes to Project fields directly - I know
there is no OnChange event for Project cells, but perhaps there might
be another way...?

Thanks
 
E

Ed Morrison

Add the line "Public WithEvents ProjApp As Application" to the top of your
vba code. Then change the object in the dropdown to ProjApp. You'll see a
whole list of available application events that you could use such as
ProjectBeforeTaskChange and ProjectBeforeAssignmentChange.
 
B

Brian K - Project MVP

Ed said:
Add the line "Public WithEvents ProjApp As Application" to the top of your
vba code. Then change the object in the dropdown to ProjApp. You'll see
a whole list of available application events that you could use such as
ProjectBeforeTaskChange and ProjectBeforeAssignmentChange.

To expand, these events will pass you a hook to the field that was
changed, the old value and the proposed new value. This would allow you to
be a bit more elegent with how you handle this log you are building.
 
B

Brian K - Project MVP

Ed said:
Add the line "Public WithEvents ProjApp As Application" to the top of your
vba code. Then change the object in the dropdown to ProjApp. You'll see
a whole list of available application events that you could use such as
ProjectBeforeTaskChange and ProjectBeforeAssignmentChange.

Ooops. I forgot to post the link.
Monitoring task changes in Project 2000
<http://techrepublic.com.com/5100-6313_11-5032122-1-1.html>

This article will help you understand how to set up your code to use these
events.
 
D

dgmoore

Thanks - this should make the process a lot more transparent and less
cumbersome. Thanks for the tip!

Dave
 
D

dgmoore

Brian - I'm having trouble seeing how to capture the current value of a
field if the procedure doesn't fire until after the value has been
changed. Can you give me a clue?

Thanks
Dave
 
B

Brian K - Project MVP

Brian - I'm having trouble seeing how to capture the current value of a
field if the procedure doesn't fire until after the value has been
changed. Can you give me a clue?

Thanks
Dave

it fires after the field is updated but before it is made 'final'. So you
get a hook into the old and new values. You get a chance to cancel the
change using these events. your code gets to fire ina limbo state that the
event creates between the time the user edits a field and the time that
they are given back conrol of the application. The "NewVal" value is what
the new value will be unless you cancel it.

Page 2 of the article it talks about putting the line "Cancel =
MonitorChanges". This is to cancel the edits. In that same place if you
checked the value of 'NewVal' you would get the value of the edit. The
'pjField' would give you the name of the field that was being edited.

Private Sub App_ProjectBeforeTaskChange(ByVal tsk As Task, _
ByVal Field As PjField, ByVal NewVal As Variant, Cancel As Boolean)

If FieldConstantToFieldName (pjField) = "Text1" Then
If NewVal = "Bad Text" then
Cancel = True
End if
End if

End Sub

So This code would check to see if the edited field was the Text1 field.
If it was it would then look to see if the new value was equal to "Bad
Text". If it was then it would cancel the edit. The effect of this code
would be that any time a user tried to enter "Bad Text" into a text1 field
the code would just return the value back to what it was before they
entered 'Bad Text'.
 

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