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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top