Closing Database Objects: Explicitly Required?

Agreed, this is from the OP.
I included it with >> << to try to avoid attributing the first part to Chris but without it his response which is what I was trying to quote would have no context.
This was certainly not an attempt by me to misquote Chris.
Sorry if this was not sufficiently clear.
 
DrallocD

In a strange way your replies in this thread are useful.
You clearly demonstrate how far some people will go to try and defend the indefensible.

When corrected you apologise but then continue to make the same mistake.

You can not stick to the facts.
You have no idea how to keep things simple.
You try to change the subject to suit your own purpose.
You misquote Microsoft.
You misquote people.
You modify what someone has said and then misquote them.
You modify a post and leave no reason.
You write VB code in a VBA thread.
You tell someone to grow up and that they lie, in public.
You then apologise for that in private, via PM.

What thinking people now have to decide is if your mistakes are deliberate or not.

If you want to continue to reply in this thread, go back to post #1 and stick to the question. Stay within the context of that question and be prepared to prove what you say with a VBA demonstration upload. I, for one, will not put up with easily retracted diatribe. I will ask for coded proof and I will attempt to pick the eyes out of it.

Remove your company name from any uploads you might make. Who you are and who you work for means absolutely nothing to me. You are traceable and even though you may not care about bringing your own name into disrepute, your company might. Make the cautious assumption that what you say on any part of the web will propagate to the entire web.

Please take the above as a warning.

As it stands at the moment; you are not part of the solution; you are part of the ongoing problem.


Chris.
 
Quoting myself.

Dralloc

Quote:
I am not sure why you say that he didn't say this
Why do you insist on misquoting. I did not say that he did not say never. That is what you said. I simply asked for you to point out where you claim he did.

I am not going to say that Chris said something when he didn't. I will leave that sort of thing up to you as you are very good at it.

Dralloc

I have still not heard you reason for misquoting me. (Post 57)

Are you simply going to deny what you said by ignoring this question.?
 
Last edited:
Hi RainLover,

I think you mean post 56.

I answered this in line 1 of Post 57 and clarified it in post 61.
 
Dralloc

Post 57 is where you made the statement and post 61 has nothing to do with me.

Are you being serious or are you toying with me.
 
Sorry, I think I may know where the confusion is.

When I said "I am not sure why you say that he didn't say this" I was referring to your comment in the previous post (56) in which you said "That is not Chris's quote."

Post 61 was for you and was explaining that it was his quote.
 
ChrisO,

If you still feel like this then I am okay to end this thread.

All of these were before post 39 when I explained, appologised and thought we were okay to move on with a more positive thread.

I did not appologize for "Grow Up". I am sorry. You were right, 24 hours was more than long enough to look at the sample code in post 5 and realise that it was down to inexperienced programming, not rs.Close. If any line of code in the exit handler can cause an error you must either prevent it by checking, in this case that rs is not null or closed before closing it, or use "on error resume next" as the first line of the exit handler. Failure to do this will cause an endless loop between the exit handler and error handler.
 
Quoting myself.

Dralloc

I am not sure why you say that he didn't say this
Why do you insist on misquoting. I did not say that he did not say never. That is what you said. I simply asked for you to point out where you claim he did.

I am not going to say that Chris said something when he didn't. I will leave that sort of thing up to you as you are very good at it.
Dralloc

I have still not heard you reason for misquoting me. (Post 57)

Are you simply going to deny what you said by ignoring this question.?

I placed in bold the issue that you are attempting to avoid.

But let me make things easy for you.

Just simply forget it. It is not possible to have a sensible discussion with a person who does not know who said what even though it is right there in front of them.

I get the feeling that someone is behind you pushing your buttons in order to confuse the original question.

To close on some friendly advise, and this goes for everyone. Do not post your business details if you don't wish to bear your all to the general public.

In your case I have been able to obtain your Resume.

EDIT

Resume for some unknown reason was in Blue. It was never a link.
 
Last edited:
Hi Rain,
In your case I have been able to obtain your Resume.
I should like to read this but I am unable to. Would you know why? or how I could get to read it?
 
Bob

I don't think that that would be the right thing to do.

Trust you understand.
 
Bob

I don't think that that would be the right thing to do.

Trust you understand.
I think I understand, but even if I don't, I think there's enough arguing here without me throwing in another bone to pick over.:D Thanks for your swift reply.
 
Bob

This argument about closing not closing has been going on for years.

It appears that no one can prove either way. I post a sample at UA some two and a half years ago. Still no one can prove it wrong.

ChrisO and I once run two or three machines overnight attempting to cause a crash or memory leakage. Nothing happened.

To me problems do occur by not closing but this is because of bad programing in the first place. So when they Explicitly Close they are overcoming the affects that they created in the first place. But this is just my educated opinion.

What both Chris and I is for someone to show proof either way. I believe that the test I posted before and a slightly different one I posted in this thread is proof that Not Closing has no effect.

Once the sub is closed everything within also closes.

If you have something to say either way please jump in. Your comments would be most welcomed.

What is frowned on is where one person quotes another who quotes another till you end up back where you started.

We need fresh information in the form of a Database that proves either way.
 
Rain,
If you have something to say either way please jump in. Your comments would be most welcomed.
Thanks for the invitation, but I don't feel I have anything of value to offer to you. I am, of course, following with interest.
 
RainLover,

Thanks for the friendly advice, this will be my last post on this thread.
 
This post from ChrisO caused him to butt heads with me (in another thread). OK, so sometimes I really AM an old goat, but I wasn't being intentionally or blindly intransigent. In a recent thread three folks found or confirmed cases where failure to clean up properly caused problems for them, specifically for hanging or orphaned processes.

https://access-programmers.co.uk/forums/showthread.php?t=288462&page=3

There are those who will say that this viewpoint of mine is wrong, perhaps, but I say that good programming habits include cleaning up your own messes in a way such that you KNOW it was properly cleaned. Leaving things to chance is like walking across a busy Interstate highway during lunch-hour traffic while blindfolded. Good odds of leaving a nasty mess behind you. (Or being the mess, yecch!)

Proactive cleanup is rarely a bad idea in ANY language I know. In another post in the referenced thread, I listed cases where cleanup WOULD be automatic and when it would not. So I'm not making a blanket statement here. But I simply didn't agree with ChrisO's position.
 
In a recent thread three folks found or confirmed cases where failure to clean up properly caused problems for them, specifically for hanging or orphaned processes.

https://access-programmers.co.uk/forums/showthread.php?t=288462&page=3

Vague hand-waving does not constitute a basis for an argument. Only reproducible evidence counts for anything. (BTW In my experience, the word "properly" is largely used used in a vain attempt to lend credence to an unsubstantiated position.)

There are in fact separate issues here that are being blended together.

One is a complete Furphy. That is the claim that failure to Set an object variable to Nothing will leave an instance of an automated application lingering after it goes out of scope. The example given is usually Excel driven from Access but it applies to all Office Applications.

Fact 1: The automated instance must have the Quit Method applied or it WILL persist after the object variable goes out of scope.

Fact 2. Regardless of whether the object variable is Set to Nothing or not, the instance of the automated application will NOT persist beyond its scope provided that it has been Quit.

Going out of scope means, for variable declared in a procedure, at the end of the procedure. For a variable declared at the top of a Class Module (including an Access Object Module), when the instance of the object is closed. For a variable declared at the top of a Standard Module, when the primary application had been Quit.

These results are consistent and reproducible by anyone who cares to perform the tests.

As I have said before, those who have experienced an automated application persisting and fixed the problem by copiously adding Close, Quit and Set to Nothing everywhere it might fit, have not discriminated the actual cause of the problem. Thus they have no grounds to be making a claim for the case that Set to Nothing is essential. It is the Quit they omitted that is the verifiable cause.

The related matter regards whether or not the absence of Set to Nothing will result in memory leakage, tying up RAM that will never be released, despite the automated application not being listed in Task Manager. This was the issue that ChrisO addressed.

Chris created object variables in millions of loops without including Set to Nothing and did not observe adverse effects. Hence his indignation was at those who insisted (without evidence) that it was a disastrous practice.

Chris was also correct that the claim had become a mantra repeated over and over by developers who had never tested anything, until it took on the status best considered a religious belief.

For the record (and I have said this before), I disagree with Chris about not closing recordsets. Nothing Earth-shatteringly bad happens but I believe the recordset is left lingering until the database engine times out.

Finally I would add that there is one very good reason for Set to Nothing. One day your boss might get someone to audit your code. They will likely be subscribers to the SetToNothing religion and will criticise your work if you omit it. The auditor will have higher status than you because your boss paid more for their advice.

Unfortunately, as in any religion, logical arguments are pointless.
 
Unfortunately, as in any religion, logical arguments are pointless.

Best oxymoron of the day award - managed to use the words "Religious Logical Arguments", in one statement. [ThumbsUp]
 
Finally I would add that there is one very good reason for Set to Nothing. One day your boss might get someone to audit your code. They will likely be subscribers to the SetToNothing religion and will criticise your work if you omit it. The auditor will have higher status than you because your boss paid more for their advice.

And here is where I find myself. This monster I have inherited was developed in 2007 by a UNIX/COBOL programmer who knew little to nothing about Access. Once he transferred out, a few hackers came in and wrote code and developed objects willy-nilly. The first time I "looked under the hood" I was dumbfounded...but that is a topic I could write a book about.

As I turned to this site and the many contributors for guidance, many practices - this one included - were made known to me which I took as gospel because, well it HAD to be, right??!?

I painstakingly went through each module and wrote in error and exit handlers and closed all record sets, databases and reset all variables BEFORE I came across this thread.

I'm not sorry I did...the process was a HUGE education for me while I made mistakes and had to figure out what I did wrong. Without going through it, most of this conversation would have meant nothing to me.

I have saved three fortunes from fortune cookies over my lifetime:

"To ensure hitting your target, it is best to shoot first and claim what is hit as your target" (doesn't apply here but it is damn good advice)

"Good judgment comes from experience. Experience comes from bad judgment"

"Wisdom is the knowledge obtained once it is too late to use it"

The last two pretty much sums up my life with Access and VBA.

And the hits just keep on coming...
 
And again, Greg, we come to the issue that people are fallible. They need to be REMINDED that there are things they should do regarding cleanup. If nothing else, the "If you opened it, close it. If you started it, stop it. If you let it run around independently, tell it to quit" advice is a simple mnemonic for people dealing with potentially complex code. Code that gets so complex that they begin to forget whether they wound the cat and put out the clock at the end of the day.

In the other thread that I referenced, I made it clear that automatic cleanup WOULD occur for some things. My point was and is that cleanup is a good idea because then you KNOW it was handled. Let me ask you this, Greg. Did your Mum ever tell you to clean your room and put your toys away even though you KNEW that tomorrow you would take them out again?

My viewpoint comes after 28 1/2 years of cleaning up other people's messes on a mainframe-class system. (It was one of my two major duties, the other being some database support work including but not limited to the Access database where I got really deep into the innards of Office.) Developers, despite knowing how to make things work, never seem to learn how to make things work without leaving behind a mess.

You say, "All you have to do is tell the app to Quit." YES, YES, YES. And without some sort of blind mantra to remind them, THEY STILL DON'T DO IT! Perhaps I've become somewhat of a "people pessimist" but my position is that without reminders, people are SLOPPY. They take short-cuts. And it was guys like me, a systems analyst / programmer / administrator who had to clean up other messes.

My unofficial title for more than a couple of years was "Senior Systems Janitor." For about the first third of those 28 1/2 years, nearly 70% of my job was cleaning up my system because users didn't clean up after themselves. When you run out of resources because people are too lazy to clean up, or they don't understand the concept of finite resources, it ends up as a bad situation. I can't tell you how many times I had to reboot a production time-share system in the middle of the day to unhang processes that would not go away on their own and that blocked operation of other users. It happened so often that I lost count.

I know, it sounds like I'm a terrible pessimist who thinks people are dumb. But that isn't really so. Let's look at Murphy's law: If it CAN go wrong, it WILL go wrong. Simple, right? No, it isn't. Because the part that everyone remembers is only HALF of the REAL Murphy's law. The other half is "So make it impossible for it to go wrong." That's why we now have polarized, asymmetrical plugs, the absence of which was the cause of his formulation of that rule in the first place.

That's why I tell people that by making it a habit to clean up after yourself, you MINIMIZE the chances of making rookie errors that leave behind a mess.

Sorry, I kind of got on my soap-box for a moment. I'll tone it down. But I WON'T erase what I wrote.
 

Users who are viewing this thread

Back
Top Bottom