MatchFound Property

Applies To

ComboBox control.

Description

Indicates whether the text that a user has typed into a combo box matches any of the entries in the list.

Syntax

object.MatchFound

The MatchFound property syntax has these parts:

Part

Description

object

Required. A valid object.


Return Values

The MatchFound property return values are:

Value

Description

True

The contents of the Value property matches one of the records in the list.

False

The contents of Value does not match any of the records in the list (default).


Remarks

The MatchFound property is read-only. It is not applicable when the MatchEntry property is set to fmMatchEntryNone.

See Also

MatchEntry property, MatchRequired property.

Example

The following example uses the MatchFound and MatchRequired properties to demonstrate additional character matching for ComboBox. The matching verification occurs in the Change event.

In this example, the user specifies whether the text portion of a ComboBox must match one of the listed items in the ComboBox. The user can specify whether matching is required by using a CheckBox and then type into the ComboBox to specify an item from its list.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • A ComboBox named ComboBox1.
  • A CheckBox named CheckBox1.
    Private Sub CheckBox1_Click()
        If CheckBox1.Value = True Then
            ComboBox1.MatchRequired = True
            MsgBox "To move the focus from the ComboBox, you must match an entry in the list or press ESC."
        Else
            ComboBox1.MatchRequired = False
            MsgBox " To move the focus from the ComboBox, just tab to or click another control. Matching is optional."
        End If
    End Sub
    
    Private Sub ComboBox1_Change()
        If ComboBox1.MatchRequired = True Then
        'MSForms handles this case automatically
        Else
            If ComboBox1.MatchFound = True Then
                MsgBox "Match Found; matching optional."
            Else
                MsgBox "Match not Found; matching optional."
            End If
        End If
    End Sub
    
    Private Sub UserForm_Initialize()
    Dim i As Integer
    
    For i = 1 To 9
        ComboBox1.AddItem "Choice " & i
    Next i
    ComboBox1.AddItem "Chocoholic"
    
    CheckBox1.Caption = "MatchRequired"
    CheckBox1.Value = True
    End Sub