I am trying to update outlook tasks from Access using VBA. See the code below. This is a procedure within a class. I first look for the task matching two criteria (this is working) and then I would like to update the task fields.
Would someone know why this is not working and if there is a way to do it?
The code is running without any error message showing up, but the task does not get updated. I would prefer not to delete the task and create a similar one (I would lose the creation date).
Many Thanks
Sub updateOutLooktask()
Dim objItems As outlook.Items
Dim ol As New outlook.Application
Dim olns As outlook.NameSpace
Dim cf As outlook.MAPIFolder
Dim myRecipient As outlook.Recipient
Dim myNamespace As outlook.NameSpace
Dim var As Collection
Dim i As Integer
Dim iTasks As Integer
Set myRecipient = myNamespace.CreateRecipient(Me.strRecipient)
myRecipient.Resolve
Set myNamespace = ol.GetNamespace("MAPI")
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetSharedDefaultFolder(myRecipient, olFolderTasks)
Set objItems = cf.Items
imax = objItems.Count
i = 1
Do While i <= imax
If objItems(i).ConversationID = Me.strConversationID And objItems(i).EntryID = Me.strEntryID Then
objItems(i).Subject = Me.strSubject
objItems(i).Body = Me.strBody
objItems(i).Importance = Me.intImportance
objItems(i).Owner = Me.strOwner
objItems(i).StartDate = Nz(Me.dtStartDate, #1/1/4501#)
objItems(i).DueDate = Nz(Me.dtDueDate, #1/1/4501#)
objItems(i).Status = Me.intStatus
objItems(i).PercentComplete = Me.intPercentComplete
objItems(i).Complete = Me.blComplete
objItems(i).TotalWork = Me.intTotalWork
objItems(i).ActualWork = Me.intActualwork
objItems(i).Categories = Me.strCategories
objItems(i).Save
Exit Do
End If
i = i + 1
Loop
End Sub