Suggestion needed in closing dB at end of the code

Voyager

Registered User.
Local time
Today, 19:21
Joined
Sep 7, 2017
Messages
95
Hi experts,
I was using the below given code to capture data in a table
Code:
sub test()
    Dim db
    Dim rst
    Set db = CurrentDb()
    Set rst = db.OpenRecordset("select * from mytable")
.
.
.
.

And close record set and database after getting data updated but I got some information stating the below will be faster
Code:
DBEngine(0)(0).openrecordset(“etbl”,dbopendynaset)
It works however I want to know whether I need to close the database at the end of the code. Like
Code:
set dB = nothing
Could you suggest?
 
Using DBEngine won't be any faster.
However using the dynaset type code will be better.

You should close anything you open - both rst and db

However if you use
Code:
Set rst=CurrentDb.openRecordset .....
you have one less variable to define, set and later close
 

Users who are viewing this thread

Back
Top Bottom