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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to step through vba code?

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
US
sorry for having this posted in "access other". now that i found this forum.

hi,
i have an access app that is giving some problem. is there anyway to step through the vba code statement by statement?
thanks.
 
Put a breakpoint on a line you want to start on (F9), once the code stops, you can press F8 to step through line by line.

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
Also you can add tool shortcuts from the debug menu bar to your toolbar. Have a look in Access help on using the Immediate Window and adding a Watch/ Quick Watch, as well as Breakpointing. Debug.Print and Message Boxes can also be useful.

Cogito eggo sum – I think, therefore I am a waffle.
 
If you want to step through from the beginning, just put your cursor in the procedure and press F8. It steps through right from the start. If you find the place that is messing things up, just click the Stop button on the Debug toolbar (I always have it displayed). In other words, if you are stepping through, you do not have to go to the end, you can stop it any time you want.

Of course if you know the "first" part - whatever that may be - is correct, and you want to step-through starting at a particular spot, then follow HQ's suggestion and use a breakpoint.

Depending on what you are needing, then absolutely, using Watches is a very good idea.

"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
As an alternative to using F9 to halt code execution you can also use the Stop statement in your code.
 
Another handy alternative to breakpoints and watches (though not as useful as a watch in all sitaution) can be
Code:
Debug.Assert [i]booleanexpression[/i]
Regards

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

You can hang outside in the sun all day tossing a ball around, or you can sit at your computer and do something that matters. - Eric Cartman

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post
 
thanks so much everybody. i got the breakpoints set and fixed the error.
 
Good. Thanks for posting a response.

"A little piece of heaven
without that awkward dying part."

advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top