OL98: SetColumns Returns Incorrect Value for Boolean Field

ID: Q184786

The information in this article applies to:

SYMPTOMS

You use the SetColumns method in the Microsoft Outlook 98 object model and get unexpected results when working with a boolean (True/False) field.

CAUSE

When you use the SetColumns method with a boolean field, the value returned for True is incorrect and will cause unexpected results if used with a logical statement such as If...Then...Else.

WORKAROUND

Use either of these two work arounds:

STATUS

Microsoft has confirmed this to be a problem in Microsoft Outlook 98.

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 the Microsoft fee-based consulting line at (800) 936-5200. 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/default.asp

The SetColumns method is used to increase performance when accessing standard Outlook fields through the Outlook object model.

For more information about using the SetColumns method, please see the following article in the Microsoft Knowledge Base:

   Article-ID: Q184462
   Title     : OL98: How to Use the SetColumns Method

Steps to Reproduce Problem

The following Microsoft Visual Basic (VB) or Microsoft Visual Basic for Applications automation code example illustrates the problem.

1. Create a Tasks folder or use an existing Tasks folder if it is empty.

2. Create two task items in the folder, setting the Subject fields to

   Test1 and Test2 or something comparable.

3. Set the status of one of the items to Complete and save the item.

4. Select the folder and then run the following automation code from VB or

   an Office application. Be sure to create a reference to the Outlook
   object library.

   Sub TestSetColumnsBoolean()
      Dim outapp As Outlook.Application
      Dim itms As Items
      Dim itm As Object
      Set outapp = New Outlook.Application
      Set itms = outapp.ActiveExplorer.CurrentFolder.Items
      itms.SetColumns "[Complete]"
      For Each itm In itms
         MsgBox itm.Subject & ":" & itm.Complete & ":" & CInt(itm.Complete)
         If itm.Complete = True Then
            MsgBox "Item is Complete"
         End If
      Next
   End Sub

You will not get a dialog box indicating one of the items is complete because neither of the fields evaluate to -1.

REFERENCES

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

   Article-ID: Q180826
   Title     : OL98: Resources for Custom Forms and Programming

   Article-ID: Q182349
   Title     : OL98: Questions About Custom Forms and Outlook Solutions

Additional query words: OutSol OutSol98 VBScript Yes No On Off
Keywords          :  
Version           : WINDOWS:
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: May 17, 1999