Text Property

Applies To

Combo Box Control, Text Box Control.

Description

You can use the Text property to set or return the text contained in a text box or the text box portion of a combo box.

Setting

The Text property holds the text you want to display in the control.

You can set this property using only a macro or Visual Basic.

Remarks

To set or return a control’s Text property, the control must have the focus (to move the focus to a control, you can use the SetFocus method or GoToControl action).

See Also

Caption Property, Name Property, Value Property.

Example

This example uses the Text property to retrieve the text box portion of a combo box and then takes an action depending on the user’s selection. The Text property setting for the combo box is assigned to the global variable GetText after a user makes a selection in the combo box.


Dim GetText As Variant    ' Goes in Declarations section of         ' code module.Combo1_AfterUpdate()
    GetText = Me!Combo1.TextSub

The Click event procedure for the DoThis command button contains the code that determines the selection and takes appropriate action.


Sub DoThis_Click()
    Select Case GetText
        Case "ComboItem1"    ' Execute if first combo item is selected.
        .
        .
        .
        Case "ComboItem2"    ' Execute if second combo item is selected.
        .
        .
        .
        Case "ComboItem3"    ' Execute if third combo item is selected.
        .
        .
        .
    End Select