insert code break

P

papa jonah

How do I insert a break into code so that I can troubleshoot code that
occurs upon opening a database?
 
S

Steven M. Britton

In the VBA Editor you can add a breakpoint by either right clicking and
selecting Toggle-> Breakpoint or you can find the line you want a breakpoint
in and click the gray area to the left which will also add a breakpoint.
Then just step through the code line by line with the Debug feature (F8) or
run the code down to your new breaks (F5)

-Steven M. Britton
 
W

Wayne Morgan

Well, the code probably doesn't run upon opening the database. It probably
runs upon opening the form that opens when your database opens. Set the
break point, close the form, then open it again from the database window.

Another option is to use Debug.Print statements in the code to send values
to the Immediate Window as the code runs.

Example:
Debug.Print MyVariable

You can also place a Stop statement ahead of where you want the code to
stop. This will stop it just like a Breakpoint.
 
O

Ofer

When the cursor on the right line code, press F9, a red line will apear, this
is the code break.
You can remove it by pressing F9 again on the same point.

When the application will be closed, all the break points will be removed.
================================================
Another way will be, to write the word
Stop
Where you want it to stop, the problem with this method, when the
application is closed the stop will remain, so you have to remember to remove
it
 
W

Wayne Morgan

PS, don't "close" the form. Change it to design view, set the break point,
then change it back to form view.
 
Top