Effects on RST in Calling Proc
- From: Tim Marshall <TIMMY!@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 03 Sep 2005 15:40:52 -0230
Here's the scenario, A2003, Jet back end, illustrated with some cut down code at the end of the post:
A proc dims a snapshot recordset (dim rst as Dao.recordset) and opens it. There are several nested do loops, going through the records in rst using .movenext. At one point in one of the loops, we'll say the rst is at record "a". Now, another subprocedure is called, passing rst to it.
In the subprocedure, the recordset goes through a do loop and the sub evaluates each record for various criteria, again, using .movenext. By the time the subproc is done with the recordset, it is at the last record. We then go back to the calling proc.
Will the recordset in the calling procedure still be at record "a"? Or will it be at the end?
I've assumed the last is true and for now, in the main procedure, I figure dimming a second recordset and setting it to the same as the first. I thought using the second set would bypass any problems running through the recordset in the second procedure.
Thanks for any comments on this.
Sub sMainProc()
dim rst as dao.recordset dim dbs as dao.database
set dbs = access.currentdb set rst = dbs.openrecordset(<sql statement>, dbopensnapshot)
with rst
if .eof = false then
.movefirst
do while .eof = false
<evaluate stuff, other loops, etc>
'At this point, rst is at record "a"
sMainProcOtherEval(rst)
'Will rst still be at "a"?
.movenext
loop
end if
.close
end with
end sub
sub sMainProcOtherEval(r as dao.recordset)
with r 'start at beginning of passed rst
.movefirst
do while .eof = false
<evaluate stuff, other loops, etc>
.movenext
loop
.close
end with
end sub -- Tim http://www.ucs.mun.ca/~tmarshal/ ^o< /#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake /^^ "What's UP, Dittoooooo?" - Ditto .
- Follow-Ups:
- Re: Effects on RST in Calling Proc
- From: rkc
- Re: Effects on RST in Calling Proc
- From: David Lloyd
- Re: Effects on RST in Calling Proc
- Prev by Date: Re: Build comma-delimited list from table
- Next by Date: Re: Problem turning off action messages in runtime - append query not working
- Previous by thread: Re: Problem turning off action messages in runtime - append query not working
- Next by thread: Re: Effects on RST in Calling Proc
- Index(es):
Relevant Pages
|