The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

InSelection Property [Access 2003 VBA Language Reference]

Office 2003

You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. Read/write Boolean.


expression Required. An expression that returns one of the objects in the Applies To list.


The InSelection property uses the following settings.

Setting Description
True The control is selected.
False The control isn't selected.

Note  This property is available only by using a macro or Visual Basic .

When a control is selected, its sizing handles are visible and it can be resized by the user. More than one control can be selected at a time.


The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. Then enter the following line in the Debug window:

? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, _
     strControlName As String) As Boolean
    Dim intI As Integer, ctl As Control
    If frm.CurrentView <> 0 Then
        ' Form is not in Design view.
        Exit Function
        For intI = 0 To frm.Count - 1
            Set ctl = frm(intI)
            If ctl.InSelection = True Then
                ' Is desired control selected?
                If UCase(ctl.Name) = UCase(strControlName) Then
                    IsControlSelected = True
                    Exit Function
                End If
                IsControlSelected = False
            End If
        Next intI
    End If
End Function

See Also | Control Object