PC Review


Reply
Thread Tools Rate Thread

Close method

 
 
George
Guest
Posts: n/a
 
      12th Sep 2003
Hi all,

Workspace, Database, Connection, and Recordset (DAO) all
have a Close method. If I don't use this Close method but
directly use Set Object = Nothing to completely destruct
the reference, is there adverse effect?

TIA.
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      12th Sep 2003
There can be an adverse effect if you close something you did not open.

Example:
Dim ws As Workspace
Set ws = dbEngine(0) 'This is already open.
'do something
ws.Close '<=WRONG!!!
Set ws = Nothing

In that case, the workspace variable is pointed at the already-open default
workspace. Closing that attempts to close the open workspace. Although
Access automatically opens it again, your there are side effects - e.g.
"Object no longer set" error when you try to access the RecordsetClone of a
form that was open at the time.

So, if you OpenRecordset, close it.
If you point a recordset variable at something that is already open (such as
the RecordsetClone of a form), do not close it.

Set all objects to Nothing before exiting your code.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"George" <(E-Mail Removed)> wrote in message
news:0cab01c3792b$af859df0$(E-Mail Removed)...
> Hi all,
>
> Workspace, Database, Connection, and Recordset (DAO) all
> have a Close method. If I don't use this Close method but
> directly use Set Object = Nothing to completely destruct
> the reference, is there adverse effect?
>
> TIA.



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I stop the close method in an auto close macro =?Utf-8?B?UGF1bA==?= Microsoft Excel Programming 2 17th Nov 2006 02:48 PM
If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws "The specified network name is no longe Daniel Microsoft C# .NET 1 8th Sep 2005 09:44 AM
If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws "The specified network name is no longe Daniel Microsoft Dot NET 3 8th Sep 2005 07:54 AM
If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws "The specified network name is no longe Daniel Microsoft Dot NET Framework 1 8th Sep 2005 04:11 AM
Close Method Ivan Weiss Microsoft VB .NET 2 17th Oct 2003 03:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:32 PM.