FIX: Sort Method May Sort Incorrectly with Recurring Appointments (254714)



The information in this article applies to:

  • Microsoft Outlook 2000

This article was previously published under Q254714

SYMPTOMS

The Sort method may sort a filtered appointments collection incorrectly when the first occurrence of a recurring AppointmentItem is also an Exception.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft Office 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

276367 OFF2000: How to Obtain the Latest Office 2000 Service Pack

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This problem was first corrected in Microsoft Office 2000 Service Pack 3.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Begin with a clean calendar.
  2. On today's date, create four appointments: "Test1", "Test2", "Test3", and "Test4".
  3. On yesterday's date, create two daily recurring appointments: "TestR1" and "TestR2".
  4. Right-click the first occurrence of "TestR1", click Delete, click Delete this one, and then click OK.
  5. In Microsoft Visual Basic 6.0, create a new standard EXE project, remove Form1, and then add a standard Module.
  6. Set a reference to "Microsoft Outlook Object Library."
  7. Paste the following code in the module code window and then execute it:

Sub Main()
  Dim oNS As NameSpace
  Dim myOLApp As Outlook.Application
  Dim myItems As Outlook.Items
  Dim oFolder As Outlook.MAPIFolder
  Dim oAppt As Outlook.AppointmentItem

  Dim sStartDate As String
  Dim sEndDate As String
  Dim sRestrict As String
  Dim sCurrentApptInfo As String

   Set myOLApp = CreateObject("Outlook.Application")
   Set oNS = myOLApp.GetNamespace("MAPI")
   
   sStartDate = "#" & Format(Date, "mm/dd/yyyy") & " 12:00 AM#"
   sEndDate = "#" & Format(DateAdd("d", 1, Date), "mm/dd/yyyy") & " 12:00 AM#"
  
  'Today's appointments.
   sRestrict = "(([start]>='" & sStartDate & "')and ([start]<'" & sEndDate & "'))"
   '''' Put this condition if you need Spanning Appointments.
   sRestrict = sRestrict & " or (([start]<='" & sStartDate & "') and ([end]>='" & sStartDate & "'))"
 
   
   Set oFolder = oNS.GetDefaultFolder(olFolderCalendar)
   Set myItems = oFolder.Items
   
   myItems.Sort "[Start]", False
   myItems.IncludeRecurrences = True
   Set myItems = myItems.Restrict(sRestrict)
   myItems.Sort "[Start]", False
     
   
   'Print the Appointment info.
   For Each oAppt In myItems
      sCurrentApptInfo = "Start: " & oAppt.Start & vbCrLf & _
                        "End: " & oAppt.End & vbCrLf & _
                        "All Day Event: " & oAppt.AllDayEvent & vbCrLf & _
                        "Is Recurring: " & oAppt.IsRecurring & vbCrLf & _
                        " - " & oAppt.Subject & " (" & oAppt.Location & ")"
     Debug.Print sCurrentApptInfo
   Next
   
   'Cleanup.
    Set oAppt = Nothing
    Set myItems = Nothing
    Set oFolder = Nothing
    Set oNS = Nothing
    Set myOLApp = Nothing
End Sub

				
The results are as follows:
  • The "TestR1" recurring appointment sorts incorrectly.
  • The "TestR2" recurring appointment sorts correctly.

Modification Type:MinorLast Reviewed:3/4/2004
Keywords:kbOffice2000SP3Fix kbAutomation kbBug kbfix kbMsg kbOfficeXPsp1Fix kbOutlookObj KB254714