How to close a file?? (1 Viewer)

rickyfong

Registered User.
Local time
Yesterday, 23:07
Joined
Nov 25, 2010
Messages
199
I have the following VBA to open a MSQUARE file....

Set TRANS3 = db.OpenRecordset("select * " & " from MSQUARE", dbOpenDynaset)

Then, I would like to close it but I tried the following coding and not working as a result!! Any idea?? Thanks!!

CLOSE
DoCMD.CLOSE
TRANS3.CLOSE
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 16:07
Joined
Jan 20, 2009
Messages
12,852
TRANS3.Close should close the recordset.

You need to provide a better description than "not working".
 

rickyfong

Registered User.
Local time
Yesterday, 23:07
Joined
Nov 25, 2010
Messages
199
May be I put it on the top of an afterupdate Sub, let me try to put it in another place. Is that Open recordset only worked within a Sub but not for all Sub Environment??
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 16:07
Joined
Jan 20, 2009
Messages
12,852
If you need the recordset outside of the sub where it is created then you certainly don't want to Close it there.

Moreover, you would need to declare the variable in the scope where you want to use it. If it is for the whole module then you need to declare it before the first sub or function in the module.
 

Users who are viewing this thread

Top Bottom