473,395 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,395 developers and data experts.

Debugging in VBA - 3) General Tips

NeoPa
32,556 Expert Mod 16PB
Table of Contents - [Debugging in VBA]
Previous Chapter - [Debugging in VBA - 2G) The Watch Pane]
-----------------------------------------------------------------------------------------------
3) General Tips.

The first and most important tip is always to work with a compiled project.

Many of the problems you're likely to come across are identified during the compile process. Compile from the VBA IDE (Integrated Development Environment) by selecting Debug | Compile {Project name}. If you ever try to run a project that won't even compile then you can expect problems. These problems are far more easily identified by a compile than when trying to run.

The next important tip is that when you are developing anything, remember to USE the debugging facilities.

Most of the facilities are only available when the code is running (although paused). While it is possible to start individual (parameterless) procedures from within the VBA editor, the usual way to get control is to put a breakpoint in the code where you want to start tracing from (See Debugging in VBA - 2A) The Code Pane (F7)) and then simply start the project in the normal way (From the Access window).

Make sure that the VBA IDE debug setting allows your code to break when an error occurs.

From the VBE screen (Alt-F11 from the main application window) select Tools / Options / General and make sure Error Trapping is set to Break on All Errors or Break in Class Module. The latter should only be necessary if you are developing any class code, but if you ever do so, finding out why it never breaks when it should can be very difficult to work out unless this is already set. The setting of Break on Unhandled Errors seems to be the default, but this can mean that any error within one or more invoked procedures, which don't themselves have any error handling, can be handled by an original, calling, procedure thereby causing the information and context associated with the actual error to be dropped completely.

Other miscellaneous tips:
  • Find out precisely where the problem occurs.
  • Display information (current contents of variables or controls etc) at various stages of the process.
  • Often overlooked - check with the Help system to make sure your use of the inbuilt functions; methods; etc is correct.
  • Shift-F2 (Definition of object) & Ctrl-Shift-F2 (Return to last position) can be extremely helpful in working out what's what and where.
May 20 '07 #1
0 6776

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Erik | last post by:
I have written an add in to the IDE that fires an event to check for processes that have started up that are in a user specified list. If one of them is found it will attach the debugger to the...
3
by: srobinson | last post by:
I am trying to debug stored procedures via VS.NET. I've set up the debugging components and made the necessary configurations (security, DCOM, etc.). I was able to start successfully debugging stored...
25
by: Jeff | last post by:
Use the MS Script Editor included free with MS Office 2002 and above, for debugging Internet Explorer (IE). This subject is of great interest to many JS developers, as there is no obvious, low...
16
by: Dean R. Henderson | last post by:
I have a project built for ASP.NET that recently started running really slow in debug mode (it takes about 10 seconds or more to step from one line of code to the next). This just started...
5
by: Velvet | last post by:
Can someone tell me to what process I need to attach to be able to step through my classic ASP code in VS.net 2003. I'm working on an XP box with IIS installed. I also have VS.net 2005 (The...
0
by: Tim Mickelson | last post by:
Hello Does there exist any debugger for the stored procedures in MySQL 5? If not is there some documentation of how debugging tips in general? Tim
5
by: phnimx | last post by:
Hi , We have developed a number of plug-in .NET Library Components that we typically deploy with our various applications by installing them into the GAC. Each of the applications contains an...
0
by: Simon | last post by:
Hi everyone, Does anyone know of any troubleshooting guides or general tips on how to fix debugging problems with ASP.net 2? I'm using the built in VS webserver and my project is definately...
0
NeoPa
by: NeoPa | last post by:
Table of Contents - Previous Chapter - Next Chapter - General Tips] ----------------------------------------------------------------------------------------------- 2G) The Watch Pane. This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.