Avatar of pcalabria
pcalabriaFlag for United States of America

asked on 

Hoping for short cut key to close vba windows in Access

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?

Microsoft OfficeMicrosoft Access

Avatar of undefined
Last Comment
Avatar of PatHartman
Flag of United States of America image

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.
Avatar of crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access

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

VBA > Module > Close Open Windows

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

Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Nice little trick Gustav!
Avatar of pcalabria
Flag of United States of America image


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

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo