OL98: Restrict May Not Work with Uncached Properties

ID: Q222484


SYMPTOMS

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


CAUSE

This may happen if all of the following are true:


RESOLUTION

Use one of the following workarounds:


STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


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/refguide/

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 98 Object Model 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  '<-- hangs on this line
            If itm.Start > #6/1/1999# Then Exit For
            Debug.Print itm.Subject & " : " & itm.Start & " : " & itm.Mileage
        Next
    End Sub 


REFERENCES

For more information about creating solutions with Microsoft Outlook 98, please see the following articles in the Microsoft Knowledge Base:

Q180826 OL98: Resources for Custom Forms and Programming
Q182349 OL98: Questions About Custom Forms and Outlook Solutions

Additional query words: OutSol OutSol98 vbscript


Keywords          : kbdta OffVBS 
Version           : 
Platform          : 
Issue type        : kbprb 

Last Reviewed: May 27, 1999