Copilot for Microsoft 365 Tech Accelerator
Feb 28 2024 07:00 AM - Feb 29 2024 10:30 AM (PST)
Microsoft Tech Community

Access Error

Copper Contributor

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?

1 Reply


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.