Hi everybody, Help
Using Access 2007 and new at working with Outlook
I created a form in Access to inport Outlook Tasks. Now I want to update the task in outlook. I created the code to import all the tasks into the form. Works great. Now I want to save the changes made back into Outlook Tasks. Borrowing code from the forum, I have changed it and put it into a module. All I am changing is the Task's body information.
The below code is to update a task in Outlook with the new information in the body. I am using the Subject to find the Task in Outlook. When code runs it skips over the updating process because the Select Case (taskType) has nothing in it even though it does in the step above it.
Can anybody tell me where I am going wrong?
Thanks Richard
Using Access 2007 and new at working with Outlook
I created a form in Access to inport Outlook Tasks. Now I want to update the task in outlook. I created the code to import all the tasks into the form. Works great. Now I want to save the changes made back into Outlook Tasks. Borrowing code from the forum, I have changed it and put it into a module. All I am changing is the Task's body information.
The below code is to update a task in Outlook with the new information in the body. I am using the Subject to find the Task in Outlook. When code runs it skips over the updating process because the Select Case (taskType) has nothing in it even though it does in the step above it.
Can anybody tell me where I am going wrong?
Thanks Richard

Code:
Option Compare Database
Option Explicit
Function UpdateTask()
Dim objApp As Object
Dim objTaskItem As TaskItem
Dim objNS As NameSpace
Dim objTasks As MAPIFolder
Dim Subject As UserProperty
Dim RecordID As UserProperty
Dim taskID As UserProperty
Dim taskType As UserProperty
Dim TaskType1 As String
TaskType1 = "IMS_Task"
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objTasks = objNS.GetDefaultFolder(olFolderTasks)
Set objTaskItem = objTasks.Items.Find("[Subject]=" & Forms!frmshowalloutlooktasks!OLSubject) ' & " AND [TaskType1]='IMS_Task'")
Set taskType = objTaskItem.UserProperties.Find("objTaskItem") '(Forms!frmshowalloutlooktasks!OLSubject) [COLOR=green]'Here the taskType shows the subject[/COLOR]
Select Case (taskType) [COLOR=green]'shows nothing[/COLOR]
Case "taskType"
If Not (Subject Is Nothing) Then
If isnull(Forms!frmshowalloutlooktasks!DateCompleted) Then
objTaskItem.Body = Forms!frmshowalloutlooktasks!OLNotes
Else
objTaskItem.Body = Forms!frmshowalloutlooktasks!OLNotes
End If
End If
Case Else
'do nothing
End Select
objTaskItem.Save
Done:
Set objApp = Nothing
Set objTaskItem = Nothing
Set objTasks = Nothing
Exit Function
Err_Handler:
MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
Resume Done
End Function