OL97: Bound Control Does Not Support Click Event (166853)



The information in this article applies to:

  • Microsoft Outlook 97

This article was previously published under Q166853

SYMPTOMS

In Microsoft Outlook 97 Visual Basic Scripting Edition (VBScript), bound controls such as the ListBox, CheckBox or OptionButton do not support the click event. When these controls are not bound however, the click event does execute. Bound means that the control has a Value property assigned.

RESOLUTION

Click event behavior varies depending upon the control. CommandButton controls, for example, can be bound to a mail field and will support the Click event. This scenario is specifically designed to display the "Select From" dialog so the user can select an email name from the address book. In order to execute a click event for other controls, make sure the control remains unbound.

If you need to bind a control to one of the item's fields, use either the Item_PropertyChange() event or the Item_CustomPropertyChange() event depending on whether the control is bound to a standard Outlook field or a user-defined field.

For more information on working with the PropertyChange and CustomPropertyChange events, please see the following articles in the Microsoft Knowledge Base:

171246 OL97: Supported Outlook Forms Control Events

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 Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site: The following example form demonstrates the click event with a bound and an unbound ListBox control:

Creating the Form and Controls

  1. Create a new e-mail message and on the message Tools menu, click Design Outlook Form.
  2. Click the (P.2) tab and on the Form menu click, Display this Page.
  3. On the Form menu, click Control Toolbox to display the toolbox.
  4. Using the Control Toolbox place two ListBoxes and one CommandButton on the form. Use the default names, ListBox1, ListBox2, and CommandButton1.

Making ListBox2 Bound

  1. Right-click ListBox2 and from the context-sensitive menu, click Properties.
  2. Click the Value tab and then click New.
  3. In the Name box, type IsBound and click OK to return to the Properties Value tab.
  4. In the Property to use list, click to select Value.
  5. In the Possible values box, type 0;1;2;3;4;5;6;7;8;9 and click OK. You have bound the ListBox2 control to the possible values of zero through nine.

Creating the Form VBScript

  1. On the form's Form menu, click View Code to open the Script Editor.
  2. Type (or copy) the following VBScript code into the editor:
        Sub CommandButton1_Click()
          ' Sets ctl to the P.2 page of the form
          Set ctl = Item.GetInspector.ModifiedFormPages("P.2")
          ' Sets ListBox1 equal to the ListBox on the control
          Set ListBox1 = ctl.controls("ListBox1")
          ' Loop to populate Listbox with values
          For i = 0 To 3
             ListBox1.AddItem cstr(i)
          Next
       End Sub
    
       Sub ListBox1_click()
          MsgBox "ListBox1 Click event fired."
       End Sub
    
       Sub ListBox2_click()
          MsgBox "ListBox2 Click event fired."
       End Sub
    
       Sub Item_CustomPropertyChange(ByVal myPropName)
          MsgBox "CustomPropertyChange event fired."
          Select Case myPropName
             Case "IsBound"
                MsgBox "Code related to field changing goes here."
             Case Else
           MsgBox "<<Select Case Else>>"
          End Select
       End Sub
    						
  3. Close the Script Editor and on the Tools menu, click Design Outlook Form.
When you click CommandButton1, ListBox1 populates with the numbers 0 through 3. ListBox2 is already bound to the values 0 through 3. If you click a value from ListBox1, you receive a message box from the click event subroutine. If you click a value from ListBox2, the click event for ListBox2 doesn't execute, but the CustomPropertyChange event subroutine does execute.

REFERENCES

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

166368 OL97: How to Get Help Programming with Outlook

170783 OL97: Q&A: Questions about Customizing or Programming Outlook


Modification Type:MajorLast Reviewed:6/23/2005
Keywords:kbcode kbinfo kbProgramming KB166853