You are not using Access the way it was meant to be used. Neither do I. :)
Try to add the following to the declarations at the top of the module:
Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal ClassName As String, ByVal WindowName As String) As Long
And then add the below to the command button that calls the function(s) that change the VBE:
Application.Echo False
SetWindowPos FindWindow("wndclass_desked_gsk", Application.VBE.MainWindow.Caption), 0&, 0&, 2000&, 1, 1, &H80 Or &H1
<run your code that calls the VBE>
Application.VBE.MainWindow.Visible = False
Application.Echo True
This will first stop Access from displaying any screen changes, move the VBE window off the screen while it is still hiding in the background, runs your code, hides the window anyway once it is off the screen, and then displays the updated screen again as normal. VBE is both off the screen, and hidden from taskbar/desktop viewing.
Now, moving the VBE window off the screen is obviously cheating... but my client doesn't care if I cheat or not.
This can be annoying (or worse) if you use this code and then need to debug unexpected errors. Also, sometimes Access will save this window position upon close, even across databases, which is undesirable. Use with caution, or plenty of time on your hands.
The internet says that the following is supposed to help too, but I haven't gotten it to work in Access 2016. Maybe you are smarter than I?
LockWindowUpdate FindWindow("wndclass_desked_gsk", Application.VBE.MainWindow.Caption)
I somehow lost the declaration for LockWindowUpdate
, but I am sure you can find it. I probably stole it from Chip Pearson or something anyway.