First Published 8 May 2024 Last Updated 2 June 2024
When Access applications are started (non-exclusively), a lock file (.laccdb or .ldb) is created. When the application is closed, the lock file is normally deleted.
However, if the application crashes, the lock file may not be deleted in the standard way and a leftover incidence of Access may be left 'hanging' in the Task Manager.
This will often prevent users being able to reopen the application. To fix this, you may need to:
1. select the instance of Microsoft Access in the Process tab (Background Processes) of Task Manager and select End Task
Alternatively, select MSACCESS.EXE in the Details tab and then click End Task
2. delete the lock file manually in File Explorer
This problem can also occur for several other reasons including poorly written code.
Recently there appear to be more frequent reports of apps closing leaving a hanging instance of Access.
For example, see this lengthy thread at: MS Tech Community forum
The thread was started in 2022 but there has been a lot of recent activity and some new information in recent months
Another similar thread also from 2022 at Microsoft Q & A forumeven identified the accessibility app, EoAExperiences.exe, as a cause.
Also see this recent thread at AccessForums.net
From the various forum responses it would appear that a number of issues may cause a hanging instance of Access to be left in Task Manager.
Suggested causes include:
a) running the Grammarly app to check spelling and grammar
b) saving Access databases to OneDrive
c) enabling the Ease of Access text cursor indicator, EoAExperiences.exe, in Windows Settings.
I have no experience with a) or b) but can confirm that in my tests the text cursor indicator reliably causes a hanging instance of Access to be left in Task Manager.
Disabling the text cursor indicator allows Access to close normally again.
UPDATE 1: 15 May 2024
I did some further investigation and found that two other accessibility features also reliably cause a hanging instance of Access.
These are the Magnifier (magnify.exe) and Narrator (narrator.exe) accessibility features.
I have also reported these as triggers to the Access team.
Here is a summary of the effects of the various Accessibility features
There is also a summary article on the AccessForever blog site.
The Access team have now investigated the issues and a fix is expected to be included in the version 2405 update around the end of May.
Until the fix is released, it may be best to avoid using those three accessibility features with Access unless these are essential for imdividual users.
UPDATE 2: 2 June 2024
Microsoft released a fix to the Current Channel with version 2405 build 17628.20110 on 29 May.
This has resolved the hanging instances of Access in the cases where accessibility features are involved. However, there appear to be other factors also involved.
Please let the AccessForever team know whether or not the new build fixes the problem for you.
Forced Shutdown
Whatever the reason(s) for the hanging instances, affected developers / end users need to know how to forcibly close Access when problems do occur.
For occasional issues, the above solution involving the use of End Task in Task Manager and deleting the lock file is likely to be sufficient.
However, where problems occur on a regular basis, there are other solutions which may be appropriate.
USE WITH CARE!
Each method carries the risk that the Access app may be left in an unstable state and/or lead to database corruption.
To minimize the risk, ensure all data has been saved and all forms and recordsets closed before running a forced shutdown.
NOTE: None of the methods deletes the lock file.
1. Taskkill (suggested by Jonathan Moll)
Run the following line of code from a command prompt, VB script or a shortcut:
cmd /c taskkill /F /IM "msaccess.exe"
IMPORTANT: This will close all instances of Access including any Access apps still open normally.
Alternatively, you can close a specific instance of Access by referencing its ProcessID (PID). The PID is displayed on the Details tab in Task Manager
Run the following line of code from e.g. a command prompt to close an Access app with a PID = 21400
cmd /c taskkill /F /PID 21400
All other open instances of Access will be unaffected using this approach
More usefully, this approach can be run from Access using VBA. The GetCurrentProcessId API will return the PID value for the current app.
This is used with a taskkill command e.g. on the close event of a hidden startup form
Private Declare PtrSafe Function GetCurrentProcessId Lib "kernel32" () As Long
'-----------------------------------------------------------
Private Sub Form_Close()
Shell "cmd /c taskkill /F /PID " & GetCurrentProcessId
End Sub
2. PowerShell (suggested by Gontran Harvey)
Create a Windows shortcut to run PowerShell with the following arguments:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command Stop-Process -Name "MsAccess"
NOTE: This will also close all instances of Access including any Access apps still open normally
3. EndTask API (suggested by Keimpe Wiersma)
This uses a different approach where Access kills its own process when the main form of the Access app is closed
To use this method, add this API code line to the declarations section of a standard module:
Public Declare PtrSafe Function EndTask Lib "user32.dll" (ByVal hWnd As LongPtr, _
ByVal fShutDown As Boolean, ByVal fForce As Boolean) As Long
Now add these 3 lines to the Close event of the main form so these run when the application is closed
Dim hWnd As LongPtr
hWnd = Application.hWndAccessApp
Call EndTask(hWnd, False, True)
The advantage of this method is that it does NOT affect any other running instances of Access.
However, in my opinion, there is a bigger disadvantage in that Access is always closed forcibly.
This gives a greater risk of corruption of both the backend data and of objects in the front end database
For this reason, Keimpe Wiersma himself states that a fresh copy of the frontend is downloaded from the network each time the application is run.
However, the risk of data corruption is still an issue.
Indeed, the Microsoft documentation strongly advises against the use of the
EndTask API function.
I do not recommend this approach. Use at your own risk
4. GetProcess API (suggested by Philipp Stiefel)
Philipp Stiefel has just released a YouTube video which uses TerminateProcess APIs to forcibly shut down Access:
Terminate Process – Workaround for Access Hanging on Close
In the video, Philipp gives similar warnings about the risks of forcibly shutting down Access databases.
Download
Click to download an example app showing the TaskKill and EndTask approaches in use. The zip file also includes two shortcuts for the TaskKill and PowerShell commands.
Forced Shutdown Approx 0.4 MB (zipped)
Feedback
Please use the contact form below to let me know whether you found this article interesting/useful or if you have any questions/comments.
Please also consider making a donation towards the costs of maintaining this website. Thank you
Colin Riddington Mendip Data Systems Last Updated 2 June 2024
Return to Code Samples Page
|
Return to Top
|