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!

Getting Into Break Mode?

Status
Not open for further replies.

iamchemist

Programmer
Mar 2, 2009
73
US
I am attempting to learn to debug VBA code in Access. I believe I understand the use of the Immediate Window and the Local Window. I understand the use of the Debug.Print command.

Would someone please explain to me how to get Access into Break Mode in order to step through and execute the VBA code one line at a time to find a bug? I am aware that I can set a Break Point in the VBA code, go back to the Database Application itself and run it to a point that will jump to the desired point in the VBA code, hit the Break Point, and stop. Then I can go to the VBA editor and step through the code beyond my Break Point. This is all pretty cumbersome. But suppose I am in the VBA Editor at exactly the point I'd like to test. Is there any way that I can force Access into Break Mode at that point in the code and let me step through the code one line at a time beyond that point to debug the code? This would seem like the most efficient way go debug the code.

Thank you! An Access VBA novice would really appreciate your input.
 
Hi,

Put your Break Point (and you can have multiple Break Points) where you need.

Run your code to the Break Point, test values and objects.

Then Step or Run to the next Break Point. Wash, rinse, repeat.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
You may also find it very handy - in a Break Mode, the yellow line indicates the line of code to be executed. You can 'grab' the yellow arrow and move it up or down to re-execute a line of code, skip a line or two, or a few, correct your code and re-execute it again, etc.

VBA_wi31br.png


---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
I'm not sure how you would be able to stop the code "at exactly the point I'd like to test". Code just keeps running unless you for instance open a dialog form which I don't believe allows you to switch to the vba view.

Duane
Minnesota
Hook'D on Access
MS Access MVP 2001-2016
 
A nice overview of VBE features you can find for instance here. Editor settings and watch window can be helpful in debugging too.

combo
 
Watch Window
faq707-4594

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Thank you very much for the references. I'll take a look.

Wayne, what I meant was that I know exactly which VBA code the Access Application will jump to and run at a certain time. By jumping into the VBA Editor, I can go to that exact Code point in that specific module. It would be nice to be able to step through that part of the code to see what some variables are doing.

Surprisingly, I find that, if my code of interest is located in a Standard Module, I can go to the code in that Module, hit CTRL+Break to enter Break Mode, and then step through the code line by line. If the code is located in the code that is associated with a Form, then this approach does not work. In that case I actually have to set a Break Point in the code, go back to the Database Application to get it to run that part of the code and stop at the Break Point, and only then can I step through the code line by line to see what some variables are doing. I don't know what the difference is.
 
Duane,

I do apologize for writing back to you and calling you "Wayne". It really was a typo.

Ron

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top