One "Resume Next" or two?

  • Thread starter Thread starter David Portwood
  • Start date Start date
D

David Portwood

Suppose I have error handling code similar to the following:

Err_MyFunction:
on error resume next
rst1.close
rst2.close

I don't want to see an error message from trying to close recordset vars
which are already closed. I actually want/expect them to be closed. But of
course, depending on where the error occurred, one or both rst vars might
still be open when the error handler fires, so I put the "resume next"
statement to guard against this eventuality.

But suppose both rst vars are already closed when the error handler fires?
In this case, both close statements should generate an error. Does the one
"resume next" cover this? Do I need two "resume next" statements?
 
You only need one Resume Next statement.

What that statement says is for every error that occurs from that point on,
just continue on to the next line.
 
I understand. Thanks, Doug.

Douglas J. Steele said:
You only need one Resume Next statement.

What that statement says is for every error that occurs from that point
on, just continue on to the next line.
 
Back
Top