Access Program Not Terminating

Novice1

Registered User.
Local time
Today, 04:39
Joined
Mar 9, 2004
Messages
385
Since I've been working with Access 2013, if I manipulate the Access objects (e.g., queries, forms, etc.), within an Access file (*.accdb) then exit the program, I have trouble reopening the *.accdb file.

If I open the Windows Task Manager and look in the Applications tab, Access appears to be closed; however, when I open the Processes tab, I can see MSACCESS.EXE *32.

If I click on the file (MSACCESS.EXE *32) then End Process, I can open the *.accdb file without any problems.

What could be causing this issue? Thanks
 
Is there any code in the app that may open a 2nd Access in the background?
 
No code for second Access Program
 
how are you exiting the program - by clicking the close button on the window bar? or by clicking an exit button on a form? If the latter, what is the code behind the button? perhaps it is code to hide the access window rather than closing it?
 
The following is the code I'm using on Exit. Based on your comments, it appears the code I have prior to DoCmd.Quit is causing the problem. How can I run the code prior to Quit so the program exits correctly? Thanks


On Error GoTo Error_Handler

Dim SignInTool As DAO.Database
Dim rstLoggedIn As DAO.Recordset

Set SignInTool = CurrentDb
Set rstLoggedIn = SignInTool.OpenRecordset("tblLoggedIn")

rstLoggedIn.MoveFirst
Do Until rstLoggedIn.EOF
If rstLoggedIn!LoggedIn = -1 And rstLoggedIn!ComputerName = fOSMachineName() And rstLoggedIn!Module = "Sign-in Tool Module" Then
rstLoggedIn.Edit
rstLoggedIn!LoggedIn = 0
rstLoggedIn!LogOutTime = Time
rstLoggedIn.Update
End If
rstLoggedIn.MoveNext
Loop

rstLoggedIn.Close
Set rstLoggedIn = Nothing

DoCmd.Quit


Error_Handler_Exit:
On Error Resume Next
Exit Sub

Error_Handler:
MsgBox Err.Description
Resume Error_Handler_Exit
 
it may be - you are missing setting SignInTool to nothing.
 
Thanks for the help. I really know very little VBA. I struggle to get where I'm at. How do you suggest I change the setting.
 
I still cannot figure out what I'm doing to prevent the closing of Access properly.

I deleted the code and used only DoCmd.Quit to close the form (fixes the problem). I went back to the original code, again no problem. So, I surmise it's something I'm doing when opening the application.

I use the following when opening a splash screen. Am I not closing properly?


On Error GoTo Error_Handler

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("tblLoggedIn")


If DCount("ComputerName", "qryNumberOfMachines") <= 25 Then

rs.AddNew
rs("LoggedIn").Value = "-1"
rs("LogInDate").Value = Date
rs("LogInTime").Value = Time
rs("UserDoDI").Value = fOSUserName()
rs("ComputerName").Value = fOSMachineName()
rs("Module").Value = "Sign-in Tool Module"
rs.Update

Else

MsgBox "Gopher may be run on no more than 25 machines", vbExclamation
DoCmd.Quit

End If

rs.Close
Set rs = Nothing



Error_Handler_Exit:
On Error Resume Next
Exit Sub

Error_Handler:
MsgBox Err.Description
Resume Error_Handler_Exit
 
In general, this is caused by something being open at the point when you are about to quit.

Here is what you need to do: In the VBA code that issues the DoCmd.Quit directive, put a breakpoint ON THAT line. It will stop before it executes the .Quit.

Now open the Locals window. You might have to diddle around a bit, but it should be possible for you to navigate to the database(0) object that would be the parent of the form, or at worst the grandparent of the form. In that object you might see a collection of recordsets. If any are still open, that is part of your problem.

If you have any code in a "BeforeUpdate" event that could cancel the update, that could also do it.

If you have opened a database object as a secondary pointer, you usually should set that object to nothing, as in Set dbobject = Nothing

This actually derives from that old book of maybe 20 years ago: "Everything I needed to know I learned in kindergarten." The basics are - if you open it, close it; if you take it out, put it back; clean up after yourself.
 
Sorry ... I still don't understand

Code:
 ...
 ...
 Loop

rstLoggedIn.Close
Set rstLoggedIn = Nothing
[COLOR=red]set SignInTool = Nothing[/COLOR]
 
DoCmd.Quit
 ...
 ...
 

Users who are viewing this thread

Back
Top Bottom