Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is Fastest? requery or close & reopen 1

Status
Not open for further replies.

Eldaria

Programmer
Sep 20, 2001
123
NL
I was wondering, does any of you guys know what would be the fastest in a loop code.

Do Until Something
Set rs = db.OpenRecordset("Select Statement",dbopensnapshot)
rs.requery
do something with the query data
change the select statement
Loop

or

Do Until Something
Set rs = db.OpenRecordset("Select Statement",dbopensnapshot)
do something with the Query data
change the select statement
rs.Close
Loop

What would be fastest? I know it is not so important for a single operation, but we are talking about this pice of code being run up to several thousends of times, and I want the fastest option.
Eldaria

That was my 25cent** of opinion.

** Inclusive Intrest, tax on interest, Genral tax, Enviromental tax, Tax, and tax on intrest, tax on fees, tax on tax, and other Various taxes and fees.
 
Eldaria,
The first example would be slower because you're opening AND requerying the rs, since you have the Set statment inside the loop, which is effectively the same as close/requery. Since you need to re-'Set' the rs anyway in order to change it's sql, the requery doesn't make sense here--it's redundant.
--Jim
 
ok....
Thanks...
Eldaria

That was my 25cent** of opinion.

** Inclusive Intrest, tax on interest, Genral tax, Enviromental tax, Tax, and tax on intrest, tax on fees, tax on tax, and other Various taxes and fees.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top