I am working on a project that requires me to be able to enumerate
through all the controls that may be selected (ie: showing their
selection handles) in a forms design view window. I have managed to
capture the active form and can iterate through all the controls on the
form but I want to be able to minimise the list to only the controls
with the selection handles are identified.
Any help would be greatly appreciated.
Greg J
The InSelection Property should be exactly what you are looking for:
'To determine the Selection status of a Control on a Form in Design View,
'execute the following code from the Debug Window (It can easily be
'modified to adapt to your specific needs)
? IsControlSelected (Forms!Customers, "CompanyName")
Function IsControlSelected(frm As Form, strControlName As String) As Integer
Dim intI As Integer, ctl As Control
If frm.CurrentView <> 0 Then
' Form is not in Design view.
Exit Function
Else
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
Else
IsControlSelected = False
End If
Next intI
End If
End Function
'Hope this works for you