Forum Discussion
Phantom Breakpoints in MS Access VBA
I've been using Access for better than 20 years at this point. Only in the last few versions have I noticed this problem of "Phantom breakpoints." This is where you'll be working on a module, or piece of VBA code behind a button, form, label, or other object, and you click the breakpoint little maroon circle out to the left of your code, and when you run the code it stops at that breakpoint. It works great!
The problem comes however when you try to un-check the maroon breakpoint - either by clicking it and it goes away, or by using the menu option "clear all breakpoints" - and then most of time time breakpoint will cease to stop the flow of the code. Unfortunately it doesn't always go away. Maybe 2 out of 10 times it will not really clear the breakpoint, and typically I don't find out about it until it's been distributed to the clients and I get a call that "Your application has stopped on that stupid yellow code thing again!" If it only happened 1 out of 100 times, that would be something I could live with, but 20% of the time is move than I can bear. Can someone people tell me of a cure for this problem? Is it something Microsoft is aware of?
Microsoft makes changes to the interface that involve the look of buttons, or the alternate row color setting on reports, which are nice I guess - I prefer the plain jane look of forms and reports, however You would think they would fix this bug before devoting time to making more "flash" for the interface.
-Breakpointed in Tampa
Although it would be nice if Microsoft found time to correct this, the likelihood of that happening in the context of far more serious, work-stop type bugs, it's not likely to be addressed very soon.
That said, I think you can more or less reliably avoid this problem by making a preventative step one of the things you do just before distributing a new version of an accdb Front End to users.
This "phantom" seems to happen when you've been editing and saving VBA during a session, adding and removing break points. What can happen is that you do end up leaving behind one of those phantoms.
The remedial step I've adopted, based on experience and results shared by others, is that you simply insert and remove one blank line in a module. Then immediately Debug-->Compile your VBA. Then immediately Save it.
Run a Compact & Repair on the accdb. Test in run mode WITHOUT stopping the code anywhere. If the phantom break point does raise its ugly head again, go to the specific procedure and repeat the steps outlined above. At some point, you'll have eliminated them all.
Not as simple, I guess, as being able to count on some automatic process might be, it is effective.
Yes, this is a known issue and had been brought to their attention in the past. There are numerous issues with each newer version of Access, just one more reason to stay with the tried, tested and true older versions!!
Feel free to send Microsoft your comments through the Feedback command in Access and also through access.uservoice.com
- George_HepworthSilver Contributor
Although it would be nice if Microsoft found time to correct this, the likelihood of that happening in the context of far more serious, work-stop type bugs, it's not likely to be addressed very soon.
That said, I think you can more or less reliably avoid this problem by making a preventative step one of the things you do just before distributing a new version of an accdb Front End to users.
This "phantom" seems to happen when you've been editing and saving VBA during a session, adding and removing break points. What can happen is that you do end up leaving behind one of those phantoms.
The remedial step I've adopted, based on experience and results shared by others, is that you simply insert and remove one blank line in a module. Then immediately Debug-->Compile your VBA. Then immediately Save it.
Run a Compact & Repair on the accdb. Test in run mode WITHOUT stopping the code anywhere. If the phantom break point does raise its ugly head again, go to the specific procedure and repeat the steps outlined above. At some point, you'll have eliminated them all.
Not as simple, I guess, as being able to count on some automatic process might be, it is effective.
- Gustav_BrockBrass Contributor
C&R also clears the issue for me, and you should always run this as one of the last steps before publishing a revision.
If C&R shouldn't work for you, a decompile will. Make a backup and then run:
MSACCESS.EXE yourdb.accdb /decompile
Then call C&R, close Access, relaunch the application, call Compile, and save the modules.
- this_is_sillyCopper ContributorUsually after a significant update, a customer emails a screen shot of the yellow highlighted code and asks "What do I do now". This problem is very random. But my solution has been to simply comment out the offending line of code, insert a blank line, and retype the exact same code on the new line. The phantom breakpoint is essentially disabled by the comment mark. Feel free to use my solution without any attributions to my genius intellect. 🙂
- Michael_BrodskyCopper Contributor
this_is_silly Yeah, how annoying. I usually cut the offending sub/function, delete a blank line and paste it back in. Same result. I've only seen this recently in Office 365 apps. Maybe in the next release, they'll introduce some new bugs/features and fix a few of the existing ones.
I normally do the same steps & in the same order.
1. Make a small change, delete & save
2. C&R
3. Decompile
I normally step 1 is sufficient.
It appears that this can happen when a breakpoint is put somewhere in the code then the VBE is closed without removing the breakpoint followed by closing Access.
When Access is reopened, there is often a phantom breakpoint where it was left in place previously.
I try to always ensure breakpoints are cleared before closing Access so rarely have the problem myself. However the Access team are aware of & looking into this elusive bugMichael_Brodsky
If you look at the monthly bug fix reports, you'll see that the Access team are working hard to clear the backlog of bugs. They prioritise those having most impact, especially where the bug can be replicated
- this_is_sillyCopper ContributorPhantom break points happen to me occasionally. My solution is to comment out the offending line with an apostrophe and then just copy and paste that code to a new line. Apparently this sets the break point on a commented out line and is ignored. I tried some of the other solutions here, but commenting out the line solved the problem for me.