Inheritance and On Error Resume Next

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.
 
D

Dev Ashish

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
 

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

Top