On Error

  • Thread starter Thread starter JT
  • Start date Start date
J

JT

I have a macro in an Access database that compacts each of the databases in a
specific folder on a shared network drive on a daily basis. It works pretty
well except when a user will occassionally leave their database open. Then
it stops the macro from running.

I was going to add an "On Error Resume Next" right before the line that
compacts the database.

My concern is the next 5 lines of code all pertain to the database that
should be closed.

Is there a way that I can use an On Error statment but have it skip the next
5 lines of code and when it resumes, pick up with the code 6 lines down?

Thanks for the help......
 
On error goto SkipToHere
'Your lines of code to skip

SkipToHere: 'Line Label
On Error GoTo YourGeneralErrorHandler

Of course, I would probably handle this routing to the procedure's error
handling routine and then depending on the error either return to the
skipToHere line with
Resume SkipToHere
or just exit the procedure completely.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
Back
Top