473,585 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Effects on RST in Calling Proc

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.currentd b
set rst = dbs.openrecords et(<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"

sMainProcOtherE val(rst)

'Will rst still be at "a"?

.movenext

loop

end if

.close

end with

end sub

sub sMainProcOtherE val(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
Nov 13 '05 #1
30 2261
Tim:

I believe your assumption about the recordset being at the last record is
correct. You are passing the recordset by reference, the default, therefore
changes made to it in the sub procedure will affect the recordset in the
calling procedure.

The ByVal keyword would normally be used to avoid this, however, when using
objects as parameters, the ByVal keyword does not have the same effect.
Below is a KB article that talks about the use of the ByVal keyword when
passing objects.

http://support.microsoft.com/default...b;en-us;138517

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Tim Marshall" <TI****@PurpleP andaChasers.Moe rtherium> wrote in message
news:df******** **@coranto.ucs. mun.ca...
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.currentd b
set rst = dbs.openrecords et(<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"

sMainProcOtherE val(rst)

'Will rst still be at "a"?

.movenext

loop

end if

.close

end with

end sub

sub sMainProcOtherE val(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
Nov 13 '05 #2
rkc
Tim Marshall wrote:
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.


Whether or not the effects of move operations on the recordset in the
procedure it's passed to are reflected in the calling procedure on
return is easily tested so I assume your question is does it make sense
to open two recordsets. I'd say no. You can always save your position
before passing the recordset and return to it after the call. I believe
that is a legitimate/safe use of a Bookmark.
Nov 13 '05 #3
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:f5******** ***********@twi ster.nyroc.rr.c om:
Whether or not the effects of move operations on the recordset in
the procedure it's passed to are reflected in the calling
procedure on return is easily tested so I assume your question is
does it make sense to open two recordsets. I'd say no. You can
always save your position before passing the recordset and return
to it after the call. I believe that is a legitimate/safe use of a
Bookmark.


I wouldn't.

I'd save the PK of the record that's current when you pass the
recordset to called procedure, then when control returns do a
FindFirst on the PK.

My rule: Never depend on bookmarks for anything where you can use
actual data to do so. Use bookmarks only for circumstances where you
*can't* use data.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
rkc
David W. Fenton wrote:
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:f5******** ***********@twi ster.nyroc.rr.c om:

Whether or not the effects of move operations on the recordset in
the procedure it's passed to are reflected in the calling
procedure on return is easily tested so I assume your question is
does it make sense to open two recordsets. I'd say no. You can
always save your position before passing the recordset and return
to it after the call. I believe that is a legitimate/safe use of a
Bookmark.

I wouldn't.

I'd save the PK of the record that's current when you pass the
recordset to called procedure, then when control returns do a
FindFirst on the PK.

My rule: Never depend on bookmarks for anything where you can use
actual data to do so. Use bookmarks only for circumstances where you
*can't* use data.


What could possibly cause just the bookmark property to fail in a
recordset opened as a snapshot?

Nov 13 '05 #5
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:Kc******** **********@twis ter.nyroc.rr.co m:
David W. Fenton wrote:
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:f5******** ***********@twi ster.nyroc.rr.c om:

Whether or not the effects of move operations on the recordset in
the procedure it's passed to are reflected in the calling
procedure on return is easily tested so I assume your question is
does it make sense to open two recordsets. I'd say no. You can
always save your position before passing the recordset and return
to it after the call. I believe that is a legitimate/safe use of
a Bookmark.

I wouldn't.

I'd save the PK of the record that's current when you pass the
recordset to called procedure, then when control returns do a
FindFirst on the PK.

My rule: Never depend on bookmarks for anything where you can use
actual data to do so. Use bookmarks only for circumstances where
you *can't* use data.


What could possibly cause just the bookmark property to fail in a
recordset opened as a snapshot?


You're asking the wrong question. I don't know that there are any
such conditions that lead to failure, but I don't know that there
are not. What I do know is that navigating by PK will *never* fail
if the recordset itself remains valid.

Why use something that is a black box about which I know very little
when there's a guaranteed method that doesn't have any blackbox
aspects to it?

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #6
rkc
David W. Fenton wrote:
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:Kc******** **********@twis ter.nyroc.rr.co m:

David W. Fenton wrote:
My rule: Never depend on bookmarks for anything where you can use
actual data to do so. Use bookmarks only for circumstances where
you *can't* use data.


What could possibly cause just the bookmark property to fail in a
recordset opened as a snapshot?

You're asking the wrong question. I don't know that there are any
such conditions that lead to failure, but I don't know that there
are not. What I do know is that navigating by PK will *never* fail
if the recordset itself remains valid.

Why use something that is a black box about which I know very little
when there's a guaranteed method that doesn't have any blackbox
aspects to it?


I don't see why you view the FindFirst method as any less of a
blackbox. The bookmark property is available for the exact purpose
of flagging and returning to a specific record in a recordset.
Saying that you can do the same in a more round about way doesn't
make it mysterious or unreliable.
Nov 13 '05 #7
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:zC******** *********@twist er.nyroc.rr.com :
David W. Fenton wrote:
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:Kc******** **********@twis ter.nyroc.rr.co m:

David W. Fenton wrote:My rule: Never depend on bookmarks for anything where you can
use actual data to do so. Use bookmarks only for circumstances
where you *can't* use data.

What could possibly cause just the bookmark property to fail in a
recordset opened as a snapshot?

You're asking the wrong question. I don't know that there are any
such conditions that lead to failure, but I don't know that there
are not. What I do know is that navigating by PK will *never*
fail if the recordset itself remains valid.

Why use something that is a black box about which I know very
little when there's a guaranteed method that doesn't have any
blackbox aspects to it?


I don't see why you view the FindFirst method as any less of a
blackbox. The bookmark property is available for the exact purpose
of flagging and returning to a specific record in a recordset.
Saying that you can do the same in a more round about way doesn't
make it mysterious or unreliable.


But we know that a bookmark is volatile data, while the primary key
is *not* volatile.

FindFirst is a method, whereas a bookmark is a form of data. I'm
advocating the use of reliable data for your navigation, and the
volatility of a bookmark makes me wary of using it except when it
can't possibly have been invalidated (i.e., immediately after a
Findfirst).

I am suspicious of any code that stores a bookmark value, as there
should always be a better method of getting back to the same record
using real data, rather than metadata about the recordset.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8
On Sat, 3 Sep 2005 17:43:54 -0400, "David Lloyd" <Da***@NoSpamPl ease.com>
wrote:
Tim:

I believe your assumption about the recordset being at the last record is
correct. You are passing the recordset by reference, the default, therefore
changes made to it in the sub procedure will affect the recordset in the
calling procedure.

The ByVal keyword would normally be used to avoid this, however, when using
objects as parameters, the ByVal keyword does not have the same effect.
Below is a KB article that talks about the use of the ByVal keyword when
passing objects.
That's not quite right. When you pass an object instance to a procedure, the
called procedure is always referring to the same object, regardless of whether
it was passed by value or by reference.

ByRef or ByVal only affects what happens if you replace the contents of the
variable itself from within the called procedure. In the case of recordset,
that means if the called procedure says Set rst = <something>, does in only
place the new recordset object in the local variable, or does it replace the
calling procedure's variable that it passed to the procedure as well.

http://support.microsoft.com/default...b;en-us;138517

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Tim Marshall" <TI****@PurpleP andaChasers.Moe rtherium> wrote in message
news:df******* ***@coranto.ucs .mun.ca...
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.currentd b
set rst = dbs.openrecords et(<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"

sMainProcOtherE val(rst)

'Will rst still be at "a"?

.movenext

loop

end if

.close

end with

end sub

sub sMainProcOtherE val(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


Nov 13 '05 #9
On Sun, 04 Sep 2005 13:49:10 -0500, "David W. Fenton"
<dX********@bwa y.net.invalid> wrote:
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:zC******* **********@twis ter.nyroc.rr.co m:
David W. Fenton wrote:
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote in
news:Kc******** **********@twis ter.nyroc.rr.co m:
David W. Fenton wrote:

>My rule: Never depend on bookmarks for anything where you can
>use actual data to do so. Use bookmarks only for circumstances
>where you *can't* use data.

What could possibly cause just the bookmark property to fail in a
recordset opened as a snapshot?
You're asking the wrong question. I don't know that there are any
such conditions that lead to failure, but I don't know that there
are not. What I do know is that navigating by PK will *never*
fail if the recordset itself remains valid.

Why use something that is a black box about which I know very
little when there's a guaranteed method that doesn't have any
blackbox aspects to it?


I don't see why you view the FindFirst method as any less of a
blackbox. The bookmark property is available for the exact purpose
of flagging and returning to a specific record in a recordset.
Saying that you can do the same in a more round about way doesn't
make it mysterious or unreliable.


But we know that a bookmark is volatile data, while the primary key
is *not* volatile.

FindFirst is a method, whereas a bookmark is a form of data. I'm
advocating the use of reliable data for your navigation, and the
volatility of a bookmark makes me wary of using it except when it
can't possibly have been invalidated (i.e., immediately after a
Findfirst).

I am suspicious of any code that stores a bookmark value, as there
should always be a better method of getting back to the same record
using real data, rather than metadata about the recordset.


A concrete reason to use FindFirst rather than a bookmark would be that a
bookmark depends on the fact that you are using the same recordset both times,
and it has not been requeried. What happens later if a need has arisen to
requery the recordset between the time the position has been recorded and when
you need to return to it?

That said, bookmarks have the advantage of not depending on a particular
definition of a row identifier for a given recordset, and doesn't require
searching on a combination of values when the row identifier for a recordset
cannot be a single value.

I don't have one single policy on this dilemma, but decide case-by-case.
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
2740
by: Steve Jorgensen | last post by:
== On Error Resume next, and Err.Number == If you want to call one of your procedures from another procedure, and check for errors afterward, you mayimagine that you should write code something like this... On Error Resuse Next MyFoo 123 lngErrNum = Err.Number On Error Goto 0
23
2353
by: Mantorok Redgormor | last post by:
Can emulation of the logical OR be done in standard C to obfuscate its use? So I don't have to use if(a||b) but instead make that even more obfuscated without its use but testing the same condition
5
3214
by: Niklaus | last post by:
This is one of the posts that i got. ------------------------------ A "side effect" of an operation is something that *happens*, not something that *is produced*. Examples: In the expression 2+2, the value 4 *is produced*. Nothing *happens*. Thus, 4 is the value of the expression, and it has no side effects. In the expression g=2.0, the...
3
1951
by: Martin Knopp | last post by:
Anybody here can shed some light on this issue? Is it at all possible to call out-of-proc COM objects from ASP.NET? If yes, what configuration settings are required? I played around many hours already trying to get all security settings done (as I did not find specific informations I followed the general rules for getting ASP to work...
2
3385
by: satishchandra999 | last post by:
I have SP, which has a cursor iterations. Need to call another SP for every loop iteration of the cursor. The pseudo code is as follows.. Create proc1 as Begin Variable declrations... declare EffectiveDate_Cursor cursor for select field1,fld2 from tab1,tab2 where tab1.effectivedate<Getdate()
14
8144
by: krishna1412 | last post by:
Currently i am working in a project of report generation in MS ACCESS. The tables are in sql server 2000. I have to write stored proc in ms access. Illustration: I am having a stored proc as follows name: myproc -------------------
2
3216
by: Anbu | last post by:
Hi all, I'm creating processes of a console based application. After proc.Start() the process is not getting terminated and the thread keeps waiting for some reponse from the process. Now I need to kill the process if it takes more time. Process proc = new Process(); proc.StartInfo.FileName = "application";
10
1753
by: mirandacascade | last post by:
Question toward the bottom of this post....background information immediately below. Access 97 SQL Server 2000 Please note: although the subject line uses the word 'bloat', this post is NOT a "what can I do to prevent bloat?" inquiry. When I searched the postings in this group for information about bloat, I believe I gained a...
4
3571
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category order, Input field and a submit button. The Category name is being fetched from the oracle db along with the corresponding Category order. In...
0
8195
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7947
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8209
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5707
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3831
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3856
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2340
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1171
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.