A number of objects may have extra properties or something where it might not exist for all instances. A good example might be finding Controlsource property on an Access.Control variable:
|
1 2 3 |
For Each ctl In Me.Controls Debug.Print ctl.ControlSource 'A potential error Next |
Not all controls have a ControlSource property and thus can fail to run. A common approach is to use OERN:
|
1 2 3 4 5 |
For Each ctl In Me.Controls On Error Resume Next Debug.Print ctl.ControlSource 'A potential error On Error GoTo 0 Next |
This will work…





