Access refuses to close (1 Viewer)

mor10

Member
Local time
Today, 05:06
Joined
Feb 15, 2016
Messages
37
For some time now Access will refuse to close when I close my database. The only way to close MSACCESS.EXE is from the task manager. If I run a repair of Access it will allow me to close it for a while, but the problem returns shortly after. After an build update the problem also goes away for a short while.

I have not been able to identify what I'm doing that causes this problem. I'm currently running version 2105 (14026.20270), but the issue has been there for months, if not years.

I'm guessing that it is something that is left open, like a recordset or an object, but I can't find a way to search for any open items.

While this is not a showstopper, it is starting to really annoy me.
 

Ranman256

Well-known member
Local time
Today, 06:06
Joined
Apr 9, 2015
Messages
4,339
did u check the bottom right corner (process running progress) to see if its:
executing a query,
or
running a repair/compact,
 

Isaac

Lifelong Learner
Local time
Today, 03:06
Joined
Mar 14, 2017
Messages
8,738
For some time now Access will refuse to close when I close my database. The only way to close MSACCESS.EXE is from the task manager. If I run a repair of Access it will allow me to close it for a while, but the problem returns shortly after. After an build update the problem also goes away for a short while.

I have not been able to identify what I'm doing that causes this problem. I'm currently running version 2105 (14026.20270), but the issue has been there for months, if not years.

I'm guessing that it is something that is left open, like a recordset or an object, but I can't find a way to search for any open items.

While this is not a showstopper, it is starting to really annoy me.
If you create a new database, and add a small amount of dummy objects (test table, test query, test form just so it has a bit of content) - and then X-out of that database, do you still see the problem?

Another thing I would check is the Unload and Close event of any and all forms or subforms (which are really just forms) which are displayed (visible or invisible) at the time when you attempt to close out of the application by clicking the X on the upper right. (For example, I can imagine a scenario in the Unload event of a form, with a MsgBox Yes/No "Do you want to exit program?" .... and if you say Yes, it quits application. If you say No, it does not quit application.....But the form is still gone, and, depending on other code inside your app, the Access Shell may appear to be gone, while technically speaking, the app is still running...invisibly).

Is clicking the X at the upper right hand corner of Access, the way you are closing the database?
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:06
Joined
Feb 28, 2001
Messages
27,001
OK, let's be a little more specific. When you say "refuse to close" does it stay on screen? Or does it leave the screen but still sit in the Process List from Task Manager?

That sounds a bit picky, but that difference makes a difference because it would tell me more about what is holding you open.

Isaac's suggestion would also make sense here. One possibility is that you have a corruption somewhere in the file. Look at this article on how to decompile a database. (It's not the first topic of the line, so look for it.)


After that, do a compact & repair then do a recompile to see if it gets better.

If not, then create an empty DB and import all content from the old DB. That option is on the Database Tools >> External Data section.

The fact that you CAN sometimes close isn't actually helpful because all it means is that there is something context sensitive here. it will take some detective work to find it.
 

mor10

Member
Local time
Today, 05:06
Joined
Feb 15, 2016
Messages
37
My database seem to be completely closed, with the .laccdb file gone as well. Access remains open. If I click to close access, it closes, but reopens immediately. Something is telling access that has to reopen, but what?

Only a repair of reboot seem to temporarily cure the problem.

I regularly run a compact & repair, and I use the decompile switch every time I'm about to produce a new .accde file. I also on occasion do a clean import into a new .accdb file.

I tried to attach a screenshot, showing that Access thinks there is no open database, since the "close" option is grayed out, but I was told I was a spammer then
 

Isaac

Lifelong Learner
Local time
Today, 03:06
Joined
Mar 14, 2017
Messages
8,738
showing that Access thinks there is no open database, since the "close" option is grayed out
Hmm...this is interesting, and shame it wouldn't let you attach a pic (possibly there is a 10-post min. before allowing or something), as I would like to better understand what this means.

Did you examine the Unload and Close events of any form(s) which are open at the time you close the db as mentioned in previous post?
PS Can you post a zipped copy of the DB here (might have to get to 10 posts on AWF before it lets you). Might require a certain amount of sanitizing, but if you can post a copy of DB where the problem is reproducible on AWF would be well worth it.
 
Last edited:

mor10

Member
Local time
Today, 05:06
Joined
Feb 15, 2016
Messages
37
Well, I seem to have found a big clew. I just rebooted and the problem went away. Then tried a few different things, not able to reproduce the problem. But then I used the Total Visual CodeTools, version 14.00.0037, "Code Cleanup", and the problem came back. To reconfirm this I did a repair, and this time I did a "Code Delivery" and the problem to come back.

I will contact FMS to see if they have a fix or recommendation.

By the way, I swear by Total Visual CodeTools as it helps me keep me maintain my system, so I hope they can come up with a fix.
 

mor10

Member
Local time
Today, 05:06
Joined
Feb 15, 2016
Messages
37
Hmm...this is interesting, and shame it wouldn't let you attach a pic (possibly there is a 10-post min. before allowing or something), as I would like to better understand what this means.

Did you examine the Unload and Close events of any form(s) which are open at the time you close the db as mentioned in previous post?
PS Can you post a zipped copy of the DB here (might have to get to 10 posts on AWF before it lets you). Might require a certain amount of sanitizing, but if you can post a copy of DB where the problem is reproducible on AWF would be well worth it.
I wish I could, but there are too many things in there I would have to remove fist. This front end is about 55Mb with a few hundred thousand lines of VBA code.
 

Attachments

  • Screenshot 2021-06-14 144948.jpg
    Screenshot 2021-06-14 144948.jpg
    64.2 KB · Views: 176

Isaac

Lifelong Learner
Local time
Today, 03:06
Joined
Mar 14, 2017
Messages
8,738
Well, I seem to have found a big clew. I just rebooted and the problem went away. Then tried a few different things, not able to reproduce the problem. But then I used the Total Visual CodeTools, version 14.00.0037, "Code Cleanup", and the problem came back. To reconfirm this I did a repair, and this time I did a "Code Delivery" and the problem to come back.

I will contact FMS to see if they have a fix or recommendation.

By the way, I swear by Total Visual CodeTools as it helps me keep me maintain my system, so I hope they can come up with a fix.
Yikes. I shy away from anyone's code/tools that I do not fully understand, in case of a case like this .... Anyway, glad you made progress and I'm sure they will be helpful. Cheers!
 

mor10

Member
Local time
Today, 05:06
Joined
Feb 15, 2016
Messages
37
Yikes. I shy away from anyone's code/tools that I do not fully understand, in case of a case like this .... Anyway, glad you made progress and I'm sure they will be helpful. Cheers!
Total Visual CodeTools is actually very good. This is the first time I've had any issue with it, and I have used it for at least a decade. I mainly use it to manage line numbers so that I can get helpful error messages, telling me exactly what line in my code that failed.
 

Isaac

Lifelong Learner
Local time
Today, 03:06
Joined
Mar 14, 2017
Messages
8,738
I mainly use it to manage line numbers so that I can get helpful error messages, telling me exactly what line in my code that failed.
That does seem handy.
 

mor10

Member
Local time
Today, 05:06
Joined
Feb 15, 2016
Messages
37
That does seem handy.
It sure is. I also have it add error handling, adding this to the end of every sub or function (with a few exceptions):

Code:
ExitHere:
1120     Exit Sub
         ' Error handling block added by VBA Code Commenter and Error Handler Add-In.
HandleErr:
1121     ReportError "Error " & Err.Number & "@" & Erl & ": " & Err.Description, "Form_CustomerService.Form_Unload"
1122     GoTo ExitHere
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 05:06
Joined
Feb 28, 2001
Messages
27,001
OK, when it pops back up on you, open the vba code page. Now open the immediate window. Do a DEBUG.PRINT like this:

Debug.Print CurrentDb.recordsets.count

If that count is not zero, you have an open recordset. I'm NOT betting on it, but I'm not done with diagnostics so don't give up on me yet.

Next thing to do is to run Task Manager by right-click in the task bar. Flip over to the "Processes" tab. Scroll until you find the MSACCESS.EXE process. See if you have more than one. (Shouldn't.) See if it is active by watching its stats. Things like CPU, Memory, I/O operations, page faulting, etc. Note that if you have not previously used Task Manager, these columns might not all be selected - but that's OK, the most important ones are there by default. There SHOULD be a column there called PID (meaning "Process ID number"). Copy that number for the MSACCESS.EXE process.

You will next want to open Performance Manager. Switch to the Task Manager's Performance tab, then see the bottom of the Task Manager box. The top section will be CPU-related. You don't care about that one. The NEXT section will be DISK-related. You DO care a LOT about this one. Scroll through there to find the disk files that your process still has opened. You can use the mouse to "grab" the top and bottom to expand or contract each section. If you mouse-click in the PID column, it will SORT by the PID column so that would make it easier to see what is open for your MSACCESS.EXE process.

The files that SHOULD be open will be MSACCESS.EXE itself, a few .DLL files, and (if there is still an open app) the name of the current App front end and back end files. After a full close, your previously open .ACCDB or .MDB should be closed. But if not, it is something you have done inside the app files.

This MIGHT not reveal the culprit file/files - but it is a way to eliminate certain possibilities.
 

isladogs

MVP / VIP
Local time
Today, 10:06
Joined
Jan 14, 2017
Messages
18,186
For info, MZ Tools has both the features you mention but without this side effect
 

mor10

Member
Local time
Today, 05:06
Joined
Feb 15, 2016
Messages
37
For info, MZ Tools has both the features you mention but without this side effect
I gave it try, and broke my code. It does not handle errors well, which made it stop halfway through updating a script, leaving it inoperable. FMS's tool deals better with this situation.
 

isladogs

MVP / VIP
Local time
Today, 10:06
Joined
Jan 14, 2017
Messages
18,186
I gave it try, and broke my code. It does not handle errors well, which made it stop halfway through updating a script, leaving it inoperable. FMS's tool deals better with this situation.
Really? I'm surprised. Both MZ Tools and the FMS suite are highly regarded by many developers.
 

Users who are viewing this thread

Top Bottom