Allen Browne
re: Do I need to set object = nothing?
It is good programming practice to close what you opened (by only what you
opened), and to dereference your objects.
In a perfect world, this would be unnecessary. Access would reliably close
anything you opened and dereference any objects you set as soon as the
procedure terminated and the objects went out of scope. We don't live in a
perfect world. There were bugs in Access 97, such that it was impossible to
close Access if you did not explicitly close the recordsets you opened.
Access would minimize to the taskbar when you tried to close it, and the
only solution was to use the task manager (Ctrl+Alt+Del) to kill it.
Even after Microsoft fixed that bug, later versions still had problems with
running out of databases if you did not explicitly set your database
variables to Nothing if they had already been set to CurrentDb(). Haven't
tried recently, but it was easy enough to do. Just run a loop that call a
function a few hundred times, and in the function set a Database type
variable to CurrentDb.
So, is it worth the effort to explicitly close what you opened and
de-reference your objects? Up to you, but the pain we had with the A97 bugs
(other causes as well as the Recordset one), and the difficulty of tracking
and fixing those left many of us rather fastidious about cleaning up after
ourselves instead of expecting the software to do it perfectly.