Detrmine if control has a certain property

  • Thread starter Thread starter Chuck
  • Start date Start date
C

Chuck

How can I determine if a control has a certain property? I want to loop
through all my controls in a form and grab all controls that have the
"Caption" property.

I know how to loop through all of them but now I have to use "On Error
Resume Next" to skip over the controls that do not have that property.

Thanks

Chuck
 
One way is to put in error handling that handles this particular error (438)

Sub MyCaptions()
On Error GoTo Proc_Err
Dim ctl As Control
For Each ctl In Me.Controls
MsgBox ctl.Name & vbCrLf & ctl.Caption
Next ctl

Proc_Exit:
Exit Sub

Proc_Err:
If Err.Number <> 438 Then
MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
Else
Resume Next
End If

End Sub
 
Back
Top