OL2000: Restrict May Not Work with Uncached Properties

ID: Q208301


The information in this article applies to:
  • Microsoft Outlook 2000


SYMPTOMS

You use the Restrict and IncludeRecurrences methods in the Outlook object model and Outlook appears to stop responding (hang), or the collection of items does not appear to be functioning correctly.


CAUSE

This may happen if all of the following are true:

  • You have items that recur and do not have an end date.
  • In the filter of the Restrict method, you did not specify an end date, so the number of items in the collection is infinite.
  • In the filter of the Restrict method, you used a property that Outlook does not cache by default.


RESOLUTION

Use one of the following workarounds:

  • Use the SetColumns method to cache the property you wish to use Restrict on. As an example, uncomment the SetColumns line in the "Steps to Reproduce the Problem" section below.


  • Alter the filter of the Restrict method so that the method will not return an infinite collection.



MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

Steps to Reproduce the Problem

  1. Create a new Calendar folder.


  2. Create three recurring appointments with a start date of 3/14/99.


  3. On two of the appointments, set the Mileage field to Test. The Mileage field does not appear on the default appointment form, but you can use the Field Chooser to add the field to a table view and then use the in-cell editing feature to set the value.


  4. With the Calendar folder selected, create a reference to the Microsoft Outlook 9.0 Object Library and run the following Visual Basic Automation code:


  5. 
    Sub RestrictTest()
        Dim outapp As Outlook.Application
        Dim itms As Outlook.Items
        Dim itmsR As Outlook.Items
        Dim itm As Outlook.AppointmentItem
        Dim strQ As String
        Set outapp = New Outlook.Application
        Set itms = outapp.ActiveExplorer.CurrentFolder.Items
        itms.IncludeRecurrences = True
        itms.Sort "[Start]"
        strQ = "[Mileage] = 'test'"
        Set itmsR = itms.Restrict(strQ)
        'itmsR.SetColumns "Mileage"
        For Each itm In itmsR
            If itm.Start > #6/1/1999# Then Exit For
            Debug.Print itm.Subject & " : " & itm.Start & " : " & itm.Mileage
        Next
    End Sub 


REFERENCES

For additional information about available resources and answers to commonly asked questions about Microsoft Outlook 2000 solutions, please see the following article in the Microsoft Knowledge Base:

Q146636 OL2000: Questions About Custom Forms and Outlook Solutions

Additional query words: OL2K OutSol OutSol2000 vbscript

Keywords : kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: November 13, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.