VBA code to close the access database without opening the application shell

I am currently using Application.Quit , which leaves the MS Access application shell open.

After processing the calling function against the target application, I remain with the rest of the open application instance; even if a particular database instance is closed.

How to make a database shell application window programmatically using VBA?

Here is an example of how a variable is created and how I close it:

 Dim appAccess As New Access.Application ' Do stuff here... appAccess.CloseCurrentDatabase 
+8
database vba access-vba ms-access ms-access-2003
source share
7 answers

You need to execute Application.Quit against the instance variable.

For example,

 Dim appAccess As New Access.Application ' Do stuff here... appAccess.Application.Quit 
+4
source share

According to the documentation: Application.Quit does the same as DoCmd.Quit . Namely

The Quit method terminates Microsoft Access. You can select one of several options to save the database object before exiting the system.

You can try to call any of them with the parameter acQuitSaveNone or 2, which "Turns off Microsoft Access without saving any objects." For further consideration, use Application.Quit , since DoCmd.Quit been added for backward compatibility for Access 95 (see Notes for the Quit method, as applicable to the DoCmd object.) Performing either of these should still perform automatic compression upon closing. if you have permissions, what could be causing your shells.

If this does not work for you, here is a somewhat extreme suggestion. Save this as a vbscript file and call it as soon as you really finish with Access. This will terminate all MSAccess processes on your Windows PC without compression or repair.

 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Process WHERE Name = 'msaccess.exe'") For Each objProcess in colProcessList objProcess.Terminate() Next 

To invoke the script, replacing [vbspath] with the actual path. If the path has spaces, be sure to use double quotes and put it in quotes:

 shell "cscript [vbspath]" 
+8
source share

I always use DoCmd.Quit acQuitSaveAll .
This works, at least in Access 2000, 2003 and 2010 (which I saw how it works).

+5
source share

Access.Quit works for me. Perhaps try instead of Application.Quit ?

If this does not solve the problem, your problem may be in another place, in which case, please tell us more about this project.

+3
source share

DoCmd.Quit acQuitSaveAll, Works for a long time. I tried all other options before, and the shell still hung.

+1
source share

Switch the form to the Design view. Set the BorderStyle form to None . From the View menu, select Form View . Note that the title bar of the form has been completely deleted.

+1
source share

You mean that after the seeming finish, the cmd.exe shell window opens and the MSACCESS.EXE process runs in the background in TaskList? And the shell is being called in the background?

0
source share

All Articles