I'm trying to delete an Outlook 2007 calendar appointment through Access 2007 with the following code:
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.
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
Any help would be greatly appreciated!
Thank you.