Use fields with controls

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

When you drag a field from the Field Chooser, the field automatically to the appropriate control. Unless you have a special requirement to use a standard control from the Control Toolbox, you should use the Field Chooser to provide access to fields on your forms.

When you put a control from the Control Toolbox on a form, you must bind the control to a form if you want to save a value to or from a control. In most cases, you bind TextBox, CheckBox, ListBox, ComboBox, and OptionButton controls to fields. Other controls, such as Label and Image controls, that contain static information with which the user does not interact are generally not bound to a field.

To bind a control to a field, right-click the control, and then click Properties on the shortcut menu. Click the Value tab. Click Choose Field, and then click a field or click New to create a custom field. Outlook fields are based on MAPI properties. In this way, the values of fields are stored with the when you save or send the item. The controls from the Control Toolbox are only the visual containers for a field on a . You can set the appearance of the control using its properties, but you cannot save a value. Controls only exist when the specific form appears that contains the controls. Fields can be used on any form. If you change a field value in one place, this value changes everywhere the field is used.

For example, to change the value of a custom field called Fax, you use the following code:

Item.UserProperties.Find("Fax").Value = "555-1234"

Note that since this is a field, you do not need to specify the page or the control the field is bound to. In the following code example, a control called txtFax is made invisible. When you work with a control, you must specify the page and the control name.

Item.GetInspector.ModifiedFormPages("General").("txtFax").Visible = False

You can bind a control to a field at by using the internal property named ItemProperty. The following example binds a TextBox to a field named Business Address.

Item.GetInspector.ModifiedFormPages("General").Textbox1.ItemProperty = "Business Address"

Note   If you create a control by dragging a plain text field to a form, you cannot bind the control to a field of a different type. For example, you cannot drag a Subject field to a form and then bind it to a field containing an Email type (such as the To field).