AC 2003 How to Force a break into debugger ?

G

Guest

Hi,

Is it possible to force an access procedure to enter the debugger and break
when there is an error? I'm trapping errors using the standard errorhandler
methods, but I am stuck in a loop, and I would like to find out where the
problem is.

Is there any code that I could place in my error handler to force vba to
stop running code and enter the debugger iwhen it encounters a particular
error number?

Here's what my error handler looks like now...

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit

In this case I get an Error# 91, but when I hit the ok button on the MsgBox
the program immediately gives me the same error again.

- David
 
G

Guest

I think there is a property called "AllowBreakIntoCode" but I'm having some
trouble finding a good example.
 
G

Guest

When you get an error message press Ctrl+Break, that will stop the code and
will locate the debuger to this line (yellow line):

Resume ErrorHandlerExit

Cange it to (adding single quote)
Resume ' ErrorHandlerExit

so it wont exit the sub
Hit the F8 key, to step through the code
The Resume will move the debuger to the line that got the error

Hints:
F8 used to step line by line in the code
F5 used to run the code without steps
F9 used to insert a code break or undo the code break where the cursoris
located in (red line)

Note:
don't forget to change this
Resume ' ErrorHandlerExit

Back to this
Resume ErrorHandlerExit
 
D

Dirk Goldgar

In
Ofer Cohen said:
When you get an error message press Ctrl+Break, that will stop the
code and will locate the debuger to this line (yellow line):

Resume ErrorHandlerExit

Cange it to (adding single quote)
Resume ' ErrorHandlerExit

so it wont exit the sub
Hit the F8 key, to step through the code
The Resume will move the debuger to the line that got the error

Hints:
F8 used to step line by line in the code
F5 used to run the code without steps
F9 used to insert a code break or undo the code break where the
cursoris located in (red line)

Note:
don't forget to change this
Resume ' ErrorHandlerExit

Back to this
Resume ErrorHandlerExit

Ofer, I don't think it's a good idea to modify code while the
application is running. That has been known to lead to corruption of
the VB project.

I suggest instead that David simply set one or more breakpoints in his
code, so that the code stops at the breakpoint(s). Then he can
single-step through it to investigate the problem.
 

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