Solved Delay in Alt+F11 (1 Viewer)

KitaYama

Well-known member
Local time
Today, 15:49
Joined
Jan 6, 2022
Messages
1,541
I need some confirmations on bellow case.

I have an accdb database with 212 forms, 72 modules, 12 class modules & 51 reports.
This database is used for developing and an accde is distributed for use.

For the past few months I'd noticed that ALT+F11 takes around 20 seconds to open VBE. Decompile/Recompile & CP showed no effect on result.
Today I noticed that if I close all opened modules before exiting VBE & the database, the next time I open the database, VBE opens instantly.

Has anybody heard/read/experienced this?
Is it normal Or there's something wrong with this DB?
Does leaving modules open while exiting DB may cause the delay in opening VBE next time?
This is the only large database I have, so I can't experiment on other databases.

Thanks
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:49
Joined
Oct 29, 2018
Messages
21,473
Hi. Yes, that is a known behavior. The more modules you had left open in the IDE, the slower it loads before you can start to work.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 01:49
Joined
Feb 28, 2001
Messages
27,186
I am thinking that this is a known larger problem that many programs try to remember their previous state at last closure and try to restore it if you enter a debugging or developing mode of access. I've heard of Word doing this, too.
 

KitaYama

Well-known member
Local time
Today, 15:49
Joined
Jan 6, 2022
Messages
1,541
Million thanks. I can sleep in peace tonight.
Was worried if it's some kind of corruption.
 

isladogs

MVP / VIP
Local time
Today, 07:49
Joined
Jan 14, 2017
Messages
18,221
For this reason, I routinely close all open modules using code before I close my larger apps
 

KitaYama

Well-known member
Local time
Today, 15:49
Joined
Jan 6, 2022
Messages
1,541
For this reason, I routinely close all open modules using code before I close my larger apps
I wish I had asked sooner.

I’m at home and can’t test your code. This evening I added the following code and it worked just fine. At least seemed to be OK. (Even if MZ-Tools has 4 buttons for this purpose). I’ll test the difference later.

Code:
Dim mModule As Access.Module

For Each mModule in CurrentProject.AllModules
    Docmd.Close acModule, mModule.Name, acvbYes
Next
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 07:49
Joined
Jan 14, 2017
Messages
18,221
I've never tried doing it that way. It looks like a much simpler approach and doesn't require the use of VBA Extensibility.
I suspect it won't be able to close the module in which that code is written but that's a minor issue.
In addition, your code will only close standard/class modules and not form/report code modules
Using my code will close all code modules

Anyway, do let me know whether that works as effectively for you as the code in my article, variations of which have circulated online for many years.

BTW its easy enough to experiment on any medium sized database by deliberately opening all code modules then closing
Repeat but apply your code then, if you can be bothered, repeat but apply my code
 
Last edited:

KitaYama

Well-known member
Local time
Today, 15:49
Joined
Jan 6, 2022
Messages
1,541
I’ll try and will report back. But it won’t be until Monday. I don’t have Accesses at home.

Thanks again.
 

isladogs

MVP / VIP
Local time
Today, 07:49
Joined
Jan 14, 2017
Messages
18,221
I tried your code from post #6 but there are 2 issues
  • acvbYes should be acSaveYes
  • it shows a type mismatch error (13) on the For Each line
This code will close all open modules (including the one its in)
Code:
Sub CloseAllModules()

Dim obj As Object
For Each obj In CurrentProject.AllModules
    DoCmd.Close acModule, obj.Name, acSaveYes
Next

End Sub

I tested it on my module code library database which has 123 code modules and it took 1.8 s
Obviously form/report modules won't get closed though you could add similar code to deal with those:

I repeated the test with the late binding version of my code as below and that took about 2/3 of the time - about 1.2 s

Code:
Function CloseAllVBEWindows()

'closes all VBE windows except this one!

On Error GoTo Err_Handler

'modified section
Dim vbWin As Object
Const vbext_wt_CodeWindow = 0
Const vbext_wt_Designer = 1

For Each vbWin In Application.VBE.Windows
    If (vbWin.Type = vbext_wt_CodeWindow Or _
        vbWin.Type = vbext_wt_Designer) And _
        Not vbWin Is Application.VBE.ActiveWindow Then
                vbWin.Close
    End If
Next

Exit_Handler:
   Exit Function

Err_Handler:
   If Err.Number = 424 Then Resume Next     'object required
   MsgBox "Error " & Err.Number & " in CloseAllVBEWindows procedure: " & Err.Description
   Resume Exit_Handler

End Function

For most practical purposes, there would be little difference in the times
 

KitaYama

Well-known member
Local time
Today, 15:49
Joined
Jan 6, 2022
Messages
1,541
acvbYes should be acSaveYes
As I said I don’t have Access at home, so the code was air code and it went as far as I remembered.

Thanks for additional info. Much appreciated. I’ll check them as soon as I’m back to my desk.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:49
Joined
Sep 12, 2006
Messages
15,656
I never thought about that. I will certainly close my modules in future, as I generally leave a lot. I have a menu button to close open forms and reports. I will see if I can add the same for modules.

@isladogs . Which Colin has thoughtfully added. :D
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 07:49
Joined
Sep 12, 2006
Messages
15,656
@isladogs

I will add a menu item to run a function call "closemodules". I assume that wouldn't open the relevant module to run the code. Anyway, I can error trap that possibility I would think..
 

isladogs

MVP / VIP
Local time
Today, 07:49
Joined
Jan 14, 2017
Messages
18,221
The first code snippet in post #8 closes that module even if its open

The second code snippet closes all except that module if you run the code direct. However if you run it from a macro it closes all code modules
See my article:
 

Users who are viewing this thread

Top Bottom