Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Thread Tools Display Modes
Old 12-22-2005, 05:38 PM
markp markp is offline
Retrict Method Condition
Join Date: Dec 2005
Posts: 1
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.

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.
    End With
End Function
Here is the code I am using to retrieve the task.
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
        For Each MyTask In MyTaskList
            Debug.Print MyTask.Subject & " - " & MyTask.CreationTime
    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?

Reply With Quote

Thread Tools
Display Modes

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 06:07 AM.

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