I've been updating a form in Access 2016 database for weeks, using vb breakpoints to troubleshoot changes. Today I come in, add breakpoints to my code, and I could tell it wasn't breaking. Looked in code and breakpoints are gone! Put them in another form in that same database, and same thing - breakpoints vanish. So, I knew it wasn't the form. Tried running a repair on the database - same thing - breakpoint vanish after they are added and saved. Tried copying a good copy of database to see if maybe the current one is corrupt - same thing - breakpoints vanish. Tried going into another database, and breakpoints work. Tried going into the good copy of the database I'm working on (one before modifications) and same thing - breakpoints vanish. Tried repairing Office- same issue. Keep in mind that breakpoints were working on Friday afternoon and I did not make any changes to config of Access. I did check to make sure Access Special Keys were checked and they were. Any other ideas???
-
I'd suggest to remove and export all forms, then repair database. After that import form-by-form and check which form causes such of strange behaviour. – Maciej Los Mar 08 '21 at 18:11
-
1@MaciejLos the easiest way to rebuild an Access DB that I have found is this version control Addin: https://github.com/joyfullservice/msaccess-vcs-integration/ It can export the whole project to source and rebuild a new ACCDB from text files. This allows you to use GIT to version control Access. – HackSlash Mar 08 '21 at 19:16
-
It's the one form that I was updating. Breakpoints worked until I imported that form, and then breakpoints didn't work on any form. What could be in that one form that's causing it to break? Is there code that stops breakpoints? FYI- I did import it from a good database, and it still happened. Or do I have to rebuild whole form? Probably 30 pages of code in this form... – user3033348 Mar 08 '21 at 20:52
-
I don't know if a full [Decompile](https://stackoverflow.com/a/3268188/3820271) can help here, but it's cheap so probably worth a try. – Andre Mar 08 '21 at 23:01
-
Corruption can happen at any time. It's not because of any code and it's not necessarily fixable. You really should rebuild. The tool I showed does it all automatically. – HackSlash Mar 08 '21 at 23:31
1 Answers
The breakpoints in the VBE are ephemeral. They don't survive certain operations like closing the document. There are a few bugs I have encountered where breakpoints exist without the red marker and also code that runs past the red marker.
The easiest to repeat is if you are calling any sort of external code. VBA is single threaded and it will often blow past breakpoints if the program flow ever leaves the current application context. For example if you call code in an Add-in or external DLL.
If you absolutely need a breakpoint in a certain part of the code for debugging then you can temporarily add a Stop
statement. I recommend making it conditional.
For example:
If myVariable = vbNullString Then Stop
This would only break if the variable is blank when you think it should not be blank. This is much like an Assert
clause in other languages.
Be sure to remove these stops when you are done debugging. A good way to do that is to make a comment like:
' BUGBUG:
Then you can quickly search for bugs before using the new version of your code in production.

- 4,944
- 2
- 18
- 44