Need to update user defined field after Task changed.....

  • Thread starter Thread starter vonclausowitz
  • Start date Start date
V

vonclausowitz

Hi All,

I use this code in Outlook.session to get the changing of a task and
then updating the field Updater:

Private Sub oTasks_ItemChange(ByVal Item As Object)

Dim oTask As TaskItem
Set oTask = Item

'If oTask.Complete = True Then
If oTask.Status = olTaskComplete Then
oTask.UserProperties("Updater") = "Lul " & Date
Else
MsgBox "Task item changed"
End If
Set oTask = Nothing

End Sub

When some user completes a task his name must be added to the field
Updater.
It doesn't seem to work however.

Marco
 
You don't have any oTask.Save statement. Note also that saving it will fire ItemChange event. Therefore, your code should check to see whether the Updater property has already been set.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Sorry, but how would what look in code? I don't have access to the earlier messages in this thread. (It helps if you quote the relevant text.)

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
My code:

Private Sub oTasks_ItemChange(ByVal Item As Object)

Dim oTask As TaskItem
Set oTask = Item

'If oTask.Complete = True Then
If oTask.Status = olTaskComplete Then
oTask.UserProperties("Updater") = "Lul " & Date
Else
MsgBox "Task item changed"
End If
Set oTask = Nothing

End Sub

Your reaction:

You don't have any oTask.Save statement. Note also that saving it will
fire ItemChange event. Therefore, your code should check to see whether
the Updater property has already been set.

Marco
 
And what in particular didn't you understand?
You don't have any oTask.Save statement.
oTask.Save

Note also that saving it will
fire ItemChange event. Therefore, your code should check to see whether
the Updater property has already been set.

If oTask.UserProperties("Updater") = "" Then
' the Updater property has never been set
' put your code here
End If

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
If I use the code as I showed you earlier it will not recognize the
fact that I completed a task. It will note a change so it will tell me:

MsgBox "Task item changed"

but the: If oTask.Status = olTaskComplete then....
is never met so it will never update my field named "Updater".

Why doesn't it identify the fact that the task was completed?

Marco
 
I would step through the code or set a watch to see what the value for oTask.Status actually returns in those cases.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
I did step through the code and found the following:

1. we use tasks which return every new day.
2. when I click a task for today as Completed the ItemChange will not
see it as Completed so my code: If oTask.Status = olTaskComplete
then.... will not work.
3. when I take a task which has already been completed and uncomplete
it and again complete it; then it will be seen as Completed and can I
run my code.

So I think it has to do with the instance of a task. When the task has
never before been completed it won't work.

Marco
 
I see you've posted the same issue in one of the Outlook programming forums with the additional -- and essential -- information that you were working with a recurring task. I'll let that discussion take over.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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

Back
Top