I created a code that will add an appointment form access to outlook successfully but I have dificulty in creating a code to add a task from access to outlook. I get an error 438 "Object doesn't support this property or method". The code I use is the following. PLEASE HELP ME.
code
---------------
Private Sub cmdAddTask_Click()
On Error GoTo Add_Err
'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
'Exit the procedure if task has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This task is already added to Microsoft Outlook"
Exit Sub
'Add a new task.
Else
Dim objOutlook As Outlook.Application
Dim objTask As Outlook.TaskItem
Set objOutlook = CreateObject("Outlook.Application")
Set objTask = objOutlook.CreateItem(olTaskItem)
With objTask
.Start = Me!TaskDate
.Subject = Me!TaskSubject
If Not IsNull(Me!TaskNotes) Then .Body = Me!TaskNotes
If Me!TaskReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If
.Save
.Close (olSave)
End With
'Release the TaskItem object variable.
Set objTask = Nothing
End If
'Release the Outlook object variable.
Set objOutlook = Nothing
'Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Task Added!"
Exit Sub
Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
----------------------
code end