Inheritance and On Error Resume Next

  • Thread starter Thread starter MDW
  • Start date Start date
M

MDW

Say I've got one sub that calls various other subs. If I
put "On Error Resume Next" in the parent sub (the one
doing all the calling), will that carry through to the
child subs (the ones being called)?

Using Access 97 if it makes a difference.
 
Say I've got one sub that calls various other subs. If I
put "On Error Resume Next" in the parent sub (the one
doing all the calling), will that carry through to the
child subs (the ones being called)?

No... What happens in this case is that the error generated in a child
sub gets bubbled up to the caller where the Resume Next statement kicks
in. To illustrate:

Sub A()
On Error Resume Next
Call SubB
Msgbox "in SubA"
End Sub

Sub B()
Err.Raise 5
Msgbox "in SubB"
End Sub

In this case, you will never see the msgbox from Sub B but Msgbox from
SubA should display without problems.

If, however, you add Resume Next to Sub B:

Sub B()
On Error Resume next
Err.Raise 5
Msgbox "in SubB"
End Sub

Now, you should see both the msgboxes. (Air code)

PS: 'Inheritance' is a totally unrelated and different term altogether
and doesn't apply in this context.

-- Dev
 
Back
Top