473,809 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Debugging in VBA - 3) General Tips

NeoPa
32,579 Recognized Expert Moderator MVP
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 6816

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

Similar topics

1
1422
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 process. This works great when the client and my server drone are the same machine, but as soon as I deploy I can not do this remotely. Does anybody have any suggestions on how I can enhance this so I can attach to a remote server process when...
3
4130
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 procs. It worked for a few hours, then, after VS.NET crashed (trying to do a search/replace in the stored proc), after restarting, I started getting an error message as follows, when I try to step into the stored proc: "An old version of SQL...
25
4333
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 cost way to do sophisticated debugging in IE6 other than to use the debugger described below, which is horribly documented otherwise. I feel debugging is an important aspect of projecting the useability of the language and needs to be made more...
16
1755
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 recently and only impacts one ASP.NET project. I have some other ASP.NET projects that I can step thru with the debugger with almost instant response. I also have some Windows Forms projects that work normally. I am running Visual Studio 2003 and...
5
2959
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 final, never installed beta) installed on this box if it makes a difference (I did not install VS Development Web Server as I'm already using the XP web server). I've seen that I need to attach to the native IIS engine, but I don't know what it's...
0
1277
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
7802
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 app.config file referencing arbitrary versions of the plug-in components they wish to consume. Here's the problem: Assuming I have installed any one of our application software,
0
1194
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 setup to allow debugging (as I debug it at work quite happily). At home though, runing from Visual Studio opens internet explorer quite happily but never hits any break points.
0
6330
NeoPa
by: NeoPa | last post by:
Table of Contents - Previous Chapter - Next Chapter - General Tips] ----------------------------------------------------------------------------------------------- 2G) The Watch Pane. This allows you to view various variables and/or objects/properties as the code progresses. This can also be used to show results of calculations and even to cause the code to stop when certain conditions are met. If there is a variable (even a property...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10635
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.