Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-22-2005, 05:38 PM
markp markp is offline
Novice
Retrict Method Condition
 
Join Date: Dec 2005
Posts: 1
markp
Default Retrict Method Condition

Hello, I'm trying to write a vba function to retrieve a task that I place in the task folder through vba.


Here is the code to place the task. This code is in an Access 2002 db program.
Code:
Function fncAddOutlookTask(TaskSubject As String, TaskBody As String, TaskDueDate As Date, _
            TaskReminder As Boolean)
    Dim OutlookApp As Outlook.Application
    Dim OutlookTask As Outlook.TaskItem

    Set OutlookApp = CreateObject("Outlook.Application")
    Set OutlookTask = OutlookApp.CreateItem(olTaskItem)

    With OutlookTask
        .Subject = TaskSubject
        .Body = TaskBody
        .DueDate = TaskDueDate
        .ReminderSet = TaskReminder
        .ReminderPlaySound = True
        .ReminderSoundFile = "C:\Windows\Media\Ding.wav"    'Modify path.
        .Save
    End With
End Function
Here is the code I am using to retrieve the task.
Code:
Function fncRetrieveOutlookTask(TaskSubject As String)
    Dim OutlookApp As Outlook.Application
    Dim MyTaskList As Outlook.Items
    Dim MyTask As TaskItem
    
    Set OutlookApp = CreateObject("Outlook.Application")
    Set MyTaskList = OutlookApp.GetNamespace("MAPI").GetDefaultFolder(olFolderTasks). _
        Items.Restrict("[Subject] Like '" & TaskSubject & "*'")
    
    If MyTaskList.Count = 1 Then
        Set MyTask = MyTaskList.Item(0)
        Debug.Print MyTask.Subject & " - " & MyTask.CreationTime
    Else
        For Each MyTask In MyTaskList
            Debug.Print MyTask.Subject & " - " & MyTask.CreationTime
        Next
    End If

End Function
I want to use the restrict method to pair down the number of tasks and the find the right one. As you can see I have used the "Like" conditional statement, but I keep getting an error with it.

Any ideas?

Thanks
Mark
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrict Method Condition Shared Contacts & Calendars. Best method crobertson Outlook 1 05-08-2009 05:47 AM
Retrict Method Condition Method to update saves to all copies aultduell Word 1 11-24-2006 12:50 PM
filesaveas method for ms project in c# results in error mikimik Project 0 10-12-2006 07:53 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft