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?

Thanks..p
Microsoft OfficeMicrosoft Access

Avatar of undefined
Last Comment
pcalabria
Avatar of PatHartman
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
http://msaccessgurus.com/VBA/Code/Mod_CloseOpenModules.htm

~crystal
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

ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
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
pcalabria
Flag of United States of America image

ASKER

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.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

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