|
The third type of value that you may need to access, particularly in
Outlook form code, is the data that a user has entered into an
unbound control on a form. (Unbound means that the text box or other
control is not tied to an Outlook property.) Outlook uses a peculiar
syntax to get the value of a control, more complicated than a VB or
VBA programmer might be accustomed to. You need to know not just the
name of the control, but also the name of the page on the Outlook
form where it appears. Get the name of the control by right-clicking
the control and viewing its Properties dialog. Then use this syntax:
The only event supported by controls on an Outlook form is the
Click event. For example, you can use the Click event to track when
a user selects a new value from a drop-down list (combo box):
However, not all controls support the Click event. The Click event
fires on a drop-down list combo box, but not if the user types a
value into a combo box with the style set to DropDownCombo (0). It
fires for label (see
To
create a hyperlink on an Outlook form for an application), frame (when the
user clicks empty space inside the frame), list box, check box, option button and command button
controls, but not for text box or spin button controls. For
list boxes, there must be at least one item in the list, and the user must click
on a list item (not in any blank area in the list box), in order for the Click
event to fire.
Another
common application of the Click event is to use a checkbox or option buttons to
change the appearance of another control. For example, you might want to change
the items displayed in a list or combo box or display a group of items that were
previously hidden. In this example, chkNeedCheck is an unbound checkbox and
frmCheckData is a frame on the General page containing bound controls where the
user can enter additional information.
Clicking on the chkNeedCheck checkbox toggles the frmCheckData's Visible
property, alternately showing and hiding the frame and all the controls it
contains. If you want to disable and enable the control, use the Enabled
property instead of Visible.
For
a demonstration of the Click event generated by unbound option
buttons, download Form
Controls Demo.zip (6kb, 30 Aug 04), unzip it, open the .oft file,
and publish that form. Then run the published form. Also see
How to
make a checkbox show and hide a frame. Besides the Click event, you can use the Item_Write, Item_Close or Item_Send
event to process the information in the unbound controls. Note,
however, that if the user changes only the data in an unbound
control -- and not the data in any bound control -- Item_Write will
not fire when the user clicks Save. |