Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handling with a Debug option 1

Status
Not open for further replies.

VictoriaLJones

Technical User
May 14, 2003
55
US
I am trying to write some Error handling for some code I have writen. However - as the data comes from external sources - it is often the case that if certain types of errors occour I will need to go into the VBA Editor, to fix the code - or go away and change the source data.. no real way round it, as the code is sequential in that if it fails on one line you cant just resume next or end it - as you cannot write over the data a second time (its taking a reconcilliation of 2 sets of data etc etc).

Sorry I am making this sound v complicated, but needless to say I cant see a way round, on occasion, having the option of breaking and going into the code to fix the error and then resume.

Is this possible - any ideas? (just in case this is important I am running Excel and Access code from Access and will need to debug/code in the Access modules).

Thanks
Victoria
 
If the code errors without error handling, it should go to the debug window anyway....

Rgds, Geoff
[blue]Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?[/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Yep - but want to be able to code for some types of errors - such as saving over old files with new extension names etc, but just breaking on any errors that I have not coded for, or unexpected errors.... perhaps this is not possible?

Victoria
 
Well, if there are specific portions of code that need error handling, set up the error handler before that bit of code then reset it with
On Error goto 0

So you could have

on error resume next
'code
'code
'code
on error goto 0
'code
'code
'code
on error goto MissThisStep
'code
'code
MissThisStep:
on error goto 0

Between the "on error goto 0" and the next "on error", no error handling will take place and therefore, the code will goto the debugger
Between the "on error resume next" etc and "on error goto 0", your specific error handling will be in effect

Rgds, Geoff
[blue]Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?[/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top