Forum Discussion
Access Error
I am trying to open an application that works with Access and I keep receiving an error code that says: There was an error compiling this function. The visual basic module contains a syntax error. Check the code, and then recompile it.
When I click ok, another message box opens for Macro Single Step.
How do I fix this issue?
- George HepworthSteel Contributor
There is an error in your VBA "somewhere". You must find it and fix it.
Start by opening the accdb with the SHIFT key held down (so-called "Shift bypass"). That bypasses any code running on the AutoExec macro when the accdb opens normally, or any code in any forms that open when the accdb opens normally.
Now, open the VBA IDE.
Make sure that EVERY module has these directives.
Next, go to Compile on the Debug menu.
This will force the VBA to compile and it will reveal the bad syntax in one or more procedures in one or more modules. Fix the syntax error(s) and recompile until the errors no longer cause compile to fail.
Save and restart.
By the way, one should ALWAYS have these two directives in EVERY module. Option explicit will save you many hours of head-scratching as you try to find syntax errors.
- Paul_BCopper Contributor
Followed the steps above, for exactly the same error, but get 'Module not found' error message. My database works fine in Access 2000, so not sure why it fails in 2010.
- George_HepworthSilver Contributor
We need more detail to be able to offer suggestions.
For example, you could show us the code that raises the error.
The error "Module not found" suggests that your code refers to a stand-alone code module which doesn't exist in that accdb.
It's possible that you have a missing reference.
It's possible that you have a typo somewhere in your code, i.e. you misspelled the name of a module or sub or function.
Trouble-shooting VBA often includes setting a breakpoint in the first line of a procedure and stepping through it line by line until you find the exact line of code that raises the error.