Deleting an appointment from Outlook Calendar 2007

eacollie

Registered User.
Local time
Today, 05:30
Joined
May 14, 2011
Messages
159
I'm trying to delete an Outlook 2007 calendar appointment through Access 2007 with the following code:
Code:
            Dim oApp As Outlook.Application 
            Dim oAppt As Outlook.AppointmentItem
            Dim oCalendar As Outlook.MAPIFolder
            Dim oNameSpace As Outlook.NameSpace
            Dim sFilter As Variant
 
            On Error Resume Next
 
            Set oApp = CreateObject("Outlook.Application") 
            Set oNameSpace = oApp.GetNamespace("MAPI")
            Set oCalendar = oNameSpace.GetDefaultFolder(olFolderCalendar)
 
 
            sFilter = "[Mileage] = " & Me!RoomRequestID.Value & ""
            Set oAppt = oCalendar.Items.Find(sFilter)
 
            'Delete this from the calendar
            If Not oCalendar Is Nothing Then
                oAppt.Delete
                Me!AddedToOutlook = False
                MsgBox "Appointment Deleted!", vbInformation
 
                Set oCalendar = Nothing
                Set oNameSpace = Nothing
                Set oApp = Nothing
             End If
In debugging, it comes up with the correct appointment item (mileage filter), but is not deleting the appointment from the Calendar.

Any help would be greatly appreciated!
Thank you.
 

Users who are viewing this thread

Back
Top Bottom