You are currently offline, waiting for your internet to reconnect

OL2002: How to Programmatically Set TextBox and CheckBox Values

This article was previously published under Q292789
This article has been archived. It is offered "as is" and will no longer be updated.
You can customize Outlook forms by using Microsoft Visual BasicScripting Edition (VBScript) and ActiveX controls. This articleillustrates how to add Outlook form controls and VBScript to an Outlookform. The example in this article uses the TextBox and CheckBox controls,and with VBScript programmatically populates those controls when you openthe form.
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 Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners -

Microsoft Advisory Services -

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:;EN-US;CNTACTMSThere are 5 steps to this example.
  • Customizing the form and adding controls
  • Binding a field to each control
  • Adding VBScript to populate the controls
  • Publishing the form
  • Using the form

Customizing the Form and Adding Controls

The following steps demonstrate how to customize a message form by making anew page visible and adding a TextBox and CheckBox control on the new page:
  1. Open a new mail message. On the Tools menu, point to Forms and then click Design This Form.
  2. Click the (P.2) tab to select the second page of the form. On the Form menu, click Display This Page. This will remove the parentheses from around P.2 and make the P.2 page viewable when the form is done.
  3. On the Form Design toolbar, click Control Toolbox and on the Controls tab click the TextBox control. Drag a TextBox onto the form. Repeat the process to place a CheckBox on the form.

Binding a Field to Each Control

While you can manipulate the appearance of a control (color, font, and such) with Advanced Properties, you must use a field to manipulate the value of a control. (Is the CheckBox selected? What text appears inside the TextBox?)

The following steps bind custom fields to each control. In this caseTextBoxField is the name of the field bound to the TextBox control.CheckBoxField is the name of the field bound to the CheckBox control.

  1. On the form, right-click the TextBox and on the shortcut menu, click Properties.
  2. Under the Value tab, click New.
  3. In the Name box, type TextBoxField. By default, the Type and Format lists should display Text.
  4. Click OK and OK to close the Properties dialog box for the TextBox control.
  5. On the form, right-click the CheckBox and on the shortcut menu, click Properties.
  6. Under the Value tab, click New.
  7. In the Name box, type CheckBoxField. In the Type list, click Yes/No. In the Format list, click True/False.
  8. Click OK and OK to close the Properties dialog box for the CheckBox control.

Adding VBScript to Populate the Controls

The following steps programmatically change each control when the formopens by changing the value of the fields to which each control is bound.The value of TextBoxField changes to: "New text." The value ofCheckBoxField changes to True. Therefore, the CheckBox appears selected.

  1. On the Form Design toolbar, click View Code to display the Script Editor. On the Script menu, click Event Handler and click to select Open in the Events list and then click Add.
  2. Type the following code between "Function Item_Open()" and "End Function":
    Set MyTextBoxField = Item.UserProperties.Find("TextBoxField")If MyTextBoxField.Value = "" Then MyTextBoxField.Value = "New text"Set MyCheckBoxField = Item.UserProperties.Find("CheckBoxField")If MyCheckBoxField.Value = 0 Then MyCheckBoxField.Value = 1					
    NOTE: The names used in quotation marks are the names of the fields which you bound to each control. The value assigned to the TextBoxField field determines what appears inside the TextBox control. The value assigned to the CheckBoxField field determines if the CheckBox control is selected.

  3. On the Script Editor File menu, click Close.

Publishing the Form

Because the programming code in this example is in the Item_Open function, it executes when you open the form. You should publish the form so that you can see the results when you open a new form.

You can publish forms several ways. This example shows how to publish yourform in your Inbox folder. Follow these steps to publish the form:
  1. On the form Tools menu, point to Forms and then click Publish Form As.
  2. In the Look In list, click to select Inbox.
  3. In the Display Name box, type MyForm.
  4. Click Publish to publish MyForm in your Inbox folder.
  5. On the form File menu, click Close. When prompted, "Do you want to save changes?" click No.

Using the Form

You published the form in your Inbox folder, so you must open your Inbox touse the form. Follow these steps to use the form:
  1. Open your Inbox.
  2. On the Actions menu, click New MyForm.
  3. In the form, click the P.2 tab.
The TextBox should contain the text "New text" and the CheckBox shouldcontain a check mark.
For additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:
287530 OL2002: Questions About Custom Forms and Outlook Solutions
OfficeKBHowTo OutSol OutSol2002
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Article ID: 292789 - Last Review: 10/25/2013 23:53:00 - Revision: 1.0

Microsoft Outlook 2002 Standard Edition

  • kbnosurvey kbarchive kbhowto KB292789