Greg, I wasn't born yesterday.
I know that if a variable is a local non-object variable in a subroutine, it needs no attention because it is part of the call frame that is automatically removed on Exit Sub/Exit Function. No problems there. Windows apps learned that trick from VAX & OpenVMS during the time that Microsoft and Digital Equipment Corporation had a teaming agreement.
If something is a local structure created by a New() function or variant thereof, it is in the program heap. Things in the heap, if carelessly left unattended and created anew without explicitly discarding or re-using them, will over a long session have the potential to fill the heap. TempVars go there, for example. And remember that if you are using a switchboard form or dispatcher form, it stays open for the life of the session. Anything it created along these lines will stick around, too.
Using 32-bit Office, you have 4 Gb of memory space because that is the memory model that was in use when Office integration started. However, specifically for Access, at least as I understand it, the database has 2 Gb of that space and the program has 2 Gb, and the program's 2 Gb has to accommodate the base .EXE code, all .DLL files, the program stack including all stack frames, and the heap. The .EXE code isn't so bad in terms of size but for a complex app, you chew up a lot of address space if you have a lot of .DLLs. If you have complex subroutines with local array variables and they do a lot of calls so that you have many frames on the stack, that gets dicey after a while. And let's NOT discuss recursive routines, which I HAVE implemented in VBA. If you then carelessly leave crap around in the heap, you face the chance that the stack will touch the heap. When that happens, it is "goodbye, application, time to shut you down."
Microsoft HAS gotten better at address layout vs. Ac97 where I first started using Access, but careless memory habits can still eat address space. And Greg, I'm TELLING you the mechanism for what happens on a failure to clean up allocated structures. What more CAN be said?
If we are talking about any kind of passive object variable, then you cannot ignore it completely because the object variable is a pointer to the "real" structure somewhere in the session's heap storage. See HEAP discussion above.
Remember also that we are running pseudo-code operations because VBA is not compiled to machine code like VB6 would be. The implementation of the
SET xxx operation has some "smarts" behind it so that a
SET xxx = Nothing can not only reset the pointer but also release the created object behind it.
Now, there can perhaps be an argument regarding whether an Exit Sub/Exit Function will detect such objects as part of the stack and will clean them up properly. Since that, too, is emulated, the emulation certainly COULD do that. I have found cases in this forum where one of these "internal" objects made an external connection that needed attention and the simple solution was to just close the object before you set it to nothing or exited, whichever came first.
If it is an application object, there is also an independent entity floating around in a separate process with its own address space. That entity needs to be told to shut itself down. You said it yourself... just tell it to Quit and it will go away. And I absolutely agree with you. After doing that, the problem devolves back to the question of whether the object-handling structure inside of Access gets cleaned by Exit Sub/Exit Function, and again, if it is based on something allocated in a subroutine, then it surely could be cleaned in that manner. But if you are not sure, there is the old adage about an ounce of prevention.
My point is that PEOPLE DON'T BOTHER with even simple programming prophylaxis unless you give them some simple reminder. For a seasoned programmer, it is not an issue. But Greg, do you HONESTLY BELIEVE that everyone we see on the forums IS a seasoned programmer? My advice is for them until they become more aware of the complexity behind the scenes.
When you were in school, did your teacher give you the ROY G BIV mnemonic for the colors of the rainbow? When you were in school, did your teacher tell you the rule about "I before E except after C"? When you were in school did you learn the rule about "drop the Y and add IES" (for pluralization of words ending in Y)? They were mnemonics designed to help you remember things until you learned them based on more advanced methods of remembering. Don't you see that I am offering the same thing?
I am beginning to suspect that you are one of the Primates in the religion of SetToNothing.
Greg, I am easy-going about this sort of stuff and sometimes I get misunderstood, so I won't let myself be insulted by that. Hell YES I am a primate... Animalia Chordata Craniata Mammalia Primata Hominidae Homo Sapiens (and these days, for some reason, the taxonomy wonks add an extra Sapiens). But I don't worship
Set To Nothing. I just offer reminders to folks on how to avoid certain pitfalls until they learn which variables, objects, and structures CAN be safely ignored - which they learn from discussions such as you and I are having right now.
Let me pose a question for you, Greg. If
Set xxx = Nothing is so unnecessary, why is there explicit syntax for it and why do MSDN sites describe it with their examples on use of structure-related objects?
Addendum: After re-reading this, I recalled an old Gary Larson cartoon from Playboy where a bunch of guys were bowing prostrate before a pedestal with a box with the big letter "N" on it. One of the worshipers whispered to the other, "Is Nothing sacred?"
For the record, I wasn't there bowing before Nothing.