We help IT Professionals succeed at work.

Hoping for short cut key to close vba windows in Access

Last Modified: 2019-03-12
I'm getting so tired of x' ing out of all of those visual basic windows in MS Access code view.
Had the same problem with A2K.. now using Office 365... have they added a function key or key shortcut for this yet???
I can't believe you experts deal with this problem..do you?

Watch Question

Distinguished Expert 2017

If your app keeps dropping into code windows, it is because you are not trapping errors correctly.  From the VBA window, go to Tools/Options and look at the error trapping setting on the General Tab.  Mine is set to break on unhandled errors.   As I discover potential errors, I either fix them permanently if my code is the problem or add handlers to give users help in recovering from the problem without dropping into code.
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and Programming
Top Expert 2015

here is some code you can use to close open modules in VBA:

VBA > Module > Close Open Windows

Daniel PineaultPresident / Owner CARDA Consultants Inc.
Distinguished Expert 2018

How exactly does it impact you if another window is open underneath the one you are working on?  If they are maximized, you only see the one you are working on.  I guess I'm just used to it.

Regardless, Mz-Tools add-in has a close all modules button amongst many other very valuable commands, definitely worth the price.

If you just want code, try
 Public Sub VBE_CloseAllModules(_
     Dim i As Integer
     Dim mods As Modules
     Set mods = Application.Modules
     For i = mods.count - 1 To 0 Step -1
         DoCmd.Close acModule, mods(i).Name, acSaveYes
     Next i
 End Sub

Open in new window

Most Valuable Expert 2015
Distinguished Expert 2018
This one is on us!
(Get your first solution completely free - no credit card required)
Daniel PineaultPresident / Owner CARDA Consultants Inc.
Distinguished Expert 2018

Nice little trick Gustav!


Thanks!  It closes the windows one at a time but sure beats using the mouse!!!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.