473,549 Members | 2,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

do i need to set objects to nothing

Hi Folk

I have about 1000 procedures in my project. Many, many of them are along
the lines of

function myfuntion () as boolean
on error goto er
'-
Dim Dbs as dao.database
Dim Rst as dao.recordset
Dim SqlS as string
'-
sqls = "..."
set dbs = currentdb
set rst = dbs.openrecords et(sqls)
do while not rst.eof
.....
rst.movenext
loop
'-
xt:
exit function
er:
msgbox error$
resume xt
end function
Should set dbs and rst to nothing or is that not necessary. If so, does
anyone know of an easy way to update all my procedures at once?

TIA

- Nicolaas
Nov 13 '05 #1
106 6371
On Sat, 14 May 2005 12:45:23 +1200, "xtra"
<wi**********@h ottermail.com> wrote:

I would, and I would DEFINITELY close the recordset object
(rst.Close).

You can write code to update your code. Check out the properties and
methods of the Module object. Not a lot of fun though. Better do it
right the first time.

-Tom.

Hi Folk

I have about 1000 procedures in my project. Many, many of them are along
the lines of

function myfuntion () as boolean
on error goto er
'-
Dim Dbs as dao.database
Dim Rst as dao.recordset
Dim SqlS as string
'-
sqls = "..."
set dbs = currentdb
set rst = dbs.openrecords et(sqls)
do while not rst.eof
.....
rst.movenext
loop
'-
xt:
exit function
er:
msgbox error$
resume xt
end function
Should set dbs and rst to nothing or is that not necessary. If so, does
anyone know of an easy way to update all my procedures at once?

TIA

- Nicolaas


Nov 13 '05 #2

"Tom van Stiphout" <no************ *@cox.net> wrote in message
news:q4******** *************** *********@4ax.c om...
On Sat, 14 May 2005 12:45:23 +1200, "xtra"
<wi**********@h ottermail.com> wrote:

I would, and I would DEFINITELY close the recordset object
(rst.Close).

You can write code to update your code. Check out the properties and
methods of the Module object. Not a lot of fun though. Better do it
right the first time.

-Tom.

Hi Folk

I have about 1000 procedures in my project. Many, many of them are along
the lines of

function myfuntion () as boolean
on error goto er
'-
Dim Dbs as dao.database
Dim Rst as dao.recordset
Dim SqlS as string
'-
sqls = "..."
set dbs = currentdb
set rst = dbs.openrecords et(sqls)
do while not rst.eof
.....
rst.movenext
loop
'-
xt:
exit function
er:
msgbox error$
resume xt
end function
Should set dbs and rst to nothing or is that not necessary. If so, does
anyone know of an easy way to update all my procedures at once?


Hoi Tom

Thank you for your reply.

Oh NO!

It looks like this requires some strategic thinking. In the help it says:

"Variables declared in a procedure are visible only within the procedure and
lose their value between calls unless they are declared Static."

But obviously that does not apply to recordsets then?

I can write a function to add the
set rst = nothing
all the way through, but as you say, it will be some work to do so.

Could I not change the declaration so that the rst and dbs automatically
loose their value, etc... when the procedure is finished?

Thanks again

- Nicolaas

Nov 13 '05 #3
On Sat, 14 May 2005 14:21:52 +1200, "xtra"
<wi**********@h ottermail.com> wrote:

The reason that doesn't work with DAO and other object models (but
does work with strings and integers) is that little pesky thing called
OLE. It uses refence counting to keep track of who has what objects
instantiated, meaning that the well behaved application must decrement
a reference count after it no longer needs it. For some reason
unbeknownst to me VBA doesn't or can't do that when an OLE variable
goes out of scope.

BTW, this is one of the main reasons .NET does NOT use reference
counting. Everyone (including MSFT) now agrees that it was a bad idea,
requiring too much dilligence on the part of the developer. The smart
marketeers now sell the garbage collector in .NET as the best thing
since sliced bread. It performs the same function as
rst.Close
set rst = Nothing
without you ever having to worry about it.

Regards,

-Tom.

"Tom van Stiphout" <no************ *@cox.net> wrote in message
news:q4******* *************** **********@4ax. com...
On Sat, 14 May 2005 12:45:23 +1200, "xtra"
<wi**********@h ottermail.com> wrote:

I would, and I would DEFINITELY close the recordset object
(rst.Close).

You can write code to update your code. Check out the properties and
methods of the Module object. Not a lot of fun though. Better do it
right the first time.

-Tom.

>Hi Folk
>
>I have about 1000 procedures in my project. Many, many of them are along
>the lines of
>
>function myfuntion () as boolean
> on error goto er
>'-
> Dim Dbs as dao.database
> Dim Rst as dao.recordset
> Dim SqlS as string
>'-
> sqls = "..."
> set dbs = currentdb
> set rst = dbs.openrecords et(sqls)
> do while not rst.eof
> .....
> rst.movenext
> loop
>'-
>xt:
> exit function
>er:
> msgbox error$
> resume xt
>end function
>
>
>Should set dbs and rst to nothing or is that not necessary. If so, does
>anyone know of an easy way to update all my procedures at once?


Hoi Tom

Thank you for your reply.

Oh NO!

It looks like this requires some strategic thinking. In the help it says:

"Variables declared in a procedure are visible only within the procedure and
lose their value between calls unless they are declared Static."

But obviously that does not apply to recordsets then?

I can write a function to add the
set rst = nothing
all the way through, but as you say, it will be some work to do so.

Could I not change the declaration so that the rst and dbs automatically
loose their value, etc... when the procedure is finished?

Thanks again

- Nicolaas


Nov 13 '05 #4
Tom van Stiphout wrote:
The reason that doesn't work with DAO and other object models (but
does work with strings and integers) is that little pesky thing called
OLE. It uses refence counting to keep track of who has what objects
instantiated, meaning that the well behaved application must decrement
a reference count after it no longer needs it. For some reason
unbeknownst to me VBA doesn't or can't do that when an OLE variable
goes out of scope.

BTW, this is one of the main reasons .NET does NOT use reference
counting. Everyone (including MSFT) now agrees that it was a bad idea,
requiring too much dilligence on the part of the developer. The smart
marketeers now sell the garbage collector in .NET as the best thing
since sliced bread. It performs the same function as
rst.Close
set rst = Nothing
without you ever having to worry about it.


TTBOMK, there are two only "ghost" pointers/objects which should be
released, viz, the DAO Recordset and the DAO Database. I routinely and
purposefully never release ADO objects. And I seldom release other
objects, only doing so when habit of years past guides my fingers.

If I am right then it is DAO, and not VBA nor OLE, which is the culprit
here.

But your post encourages me. If garbage collection is a major selling
point of .Net then perhaps I am right in looking for another technology.
I am reminded of a Pontiac commercial in which two sophisticated young
men open the hood and look at each other. One whistles and the other
whispers sotto voce, "Transverse ly mounted V6!". Way to go boys, you're
twenty years behind the times and you want us to be impressed!

IMO, while Access is a fine GUI, DAO and VBA are archaic, clumsy and
inefficient.

--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #5
"Tom van Stiphout" wrote
You can write code to update your
code. Check out the properties and
methods of the Module object. Not
a lot of fun though. Better do it
right the first time.


Work on a copy, and save your code-modification-code. Then, if you didn't
get it right the first time, make another copy, paste in your code-mod-code,
fix it, save it, and try again.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #6
"Lyle Fairfield" wrote
IMO, while Access is a fine GUI, DAO
and VBA are archaic, clumsy and
inefficient.


Maybe that's why some of us are so empathetic toward DAO and VBA -- because
we can relate to "archaic, clumsy, and inefficient". <GRIN>
Nov 13 '05 #7

"Tom van Stiphout" <no************ *@cox.net> wrote in message
news:m3******** *************** *********@4ax.c om...
On Sat, 14 May 2005 14:21:52 +1200, "xtra"
<wi**********@h ottermail.com> wrote:

The reason that doesn't work with DAO and other object models (but
does work with strings and integers) is that little pesky thing called
OLE. It uses refence counting to keep track of who has what objects
instantiated, meaning that the well behaved application must decrement
a reference count after it no longer needs it. For some reason
unbeknownst to me VBA doesn't or can't do that when an OLE variable
goes out of scope.

BTW, this is one of the main reasons .NET does NOT use reference
counting. Everyone (including MSFT) now agrees that it was a bad idea,
requiring too much dilligence on the part of the developer. The smart
marketeers now sell the garbage collector in .NET as the best thing
since sliced bread. It performs the same function as
rst.Close
set rst = Nothing
without you ever having to worry about it.

Regards,

-Tom.

"Tom van Stiphout" <no************ *@cox.net> wrote in message
news:q4******* *************** **********@4ax. com...
On Sat, 14 May 2005 12:45:23 +1200, "xtra"
<wi**********@h ottermail.com> wrote:

I would, and I would DEFINITELY close the recordset object
(rst.Close).

You can write code to update your code. Check out the properties and
methods of the Module object. Not a lot of fun though. Better do it
right the first time.

-Tom.
>Hi Folk
>
>I have about 1000 procedures in my project. Many, many of them are along >the lines of
>
>function myfuntion () as boolean
> on error goto er
>'-
> Dim Dbs as dao.database
> Dim Rst as dao.recordset
> Dim SqlS as string
>'-
> sqls = "..."
> set dbs = currentdb
> set rst = dbs.openrecords et(sqls)
> do while not rst.eof
> .....
> rst.movenext
> loop
>'-
>xt:
> exit function
>er:
> msgbox error$
> resume xt
>end function
>
>
>Should set dbs and rst to nothing or is that not necessary. If so, does >anyone know of an easy way to update all my procedures at once?


Hoi Tom

Thank you for your reply.

Oh NO!

It looks like this requires some strategic thinking. In the help it says:
"Variables declared in a procedure are visible only within the procedure andlose their value between calls unless they are declared Static."

But obviously that does not apply to recordsets then?

I can write a function to add the
set rst = nothing
all the way through, but as you say, it will be some work to do so.

Could I not change the declaration so that the rst and dbs automatically
loose their value, etc... when the procedure is finished?

Thanks again

- Nicolaas


Hi Guys
Thank you for all your interesting and entertaining messages.

I was wondering, can I write a function along the lines of

Function GC ()
for each object
if object.name = rst
rst.close
set rst = nothing
end if
next object
end function
????

That would solve my problem as all my functions end in

xt:
exit function

then it would be a simple replace.

I have recently been doing a lot of PHP/MySql and I found it to be very
clean and simple. HOWEVER, there are some aspects of Access that still make
it very powerful. In terms of GUI, you can really cranck it without having
to work with clumsy HTML

- Nicolaas
Nov 13 '05 #8
xtra wrote:
I was wondering, can I write a function along the lines of

Function GC ()
for each object
if object.name = rst
rst.close
set rst = nothing
end if
next object
end function
????


You could write any function you want, but it may not work. I have my
doubts about this one, in fact I would give you a thousand to one that
it would not.

If I were doing the code writing I would examine my code carefully and
write code to change it by

1. removing redundant DAO references eg. SET db=CurrentDB
2. changing the other DAO lines to ADO

first of course I would practise with a mock up.

ADO objects do not require release.

Oh yes, it's unlikely I would go through the Module object thing. It's
too clumsy and makes a mess of ones screen. I would SaveToFile the
modules, open the files with low-level open commands, stroke the code
using the Replace function a lot, save the revisions with new names and
then LoadFromFile. The original SaveToOFile files would be my safeties.
Probably the whole thing could be done with less than 50 lines of code.
--
--
Lyle

"The aim of those who try to control thought is always the same. They
find one single explanation of the world, one system of thought and
action that will (they believe) cover everything; and then they try to
impose that on all thinking people."
- Gilbert Highet
Nov 13 '05 #9
Larry Linson wrote:
"Lyle Fairfield" wrote
> IMO, while Access is a fine GUI, DAO
> and VBA are archaic, clumsy and
> inefficient.


Maybe that's why some of us are so empathetic toward DAO and VBA -- because
we can relate to "archaic, clumsy, and inefficient". <GRIN>


What, are there others who type their answers with one finger of their
left hand because the arthritis, calcium deposits and bone chips of the
right shoulder that used to power that high hard fastball (way too many
times) in our youth, have claimed their revenge?

--
--
Lyle
Nov 13 '05 #10

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

Similar topics

2
1922
by: Bobby | last post by:
Hello everyone I have a question. The school I am working for is in the beginning process of having a webpage that will direct students to download there homework and be able to view there info like test scores and etc(the homework and info page will reside on our webservers at the school on the local intranet network). Now what I need is a...
2
1783
by: Lin Ma | last post by:
Hello, I have a general question. In my asp page, I have DB connection, Recordset, and some variables like dim name, conn, rs set conn = Server.CreateObject("ADODB.Connection") .... set rs= server.createObject("ADODB.Recordset")
16
2193
by: Joel Finkel | last post by:
Folks, I am confused as to how to implement the following solution. I have a series of processing steps, each of which contains similar features (forms, etc). Therefore, I create a base class, Step, and subclass from that for specific steps. The Step class has a method, Execute(), which can return either Success or Failure. I have a...
5
3772
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public List<RoleData> GetRoles() { return GetRoles(null, false); }
18
2314
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before. Here's the scenario: We have a base class with all virtual functions. We'll call this the Animal class. We then make two classes Fish and Bird...
4
14897
by: Paul H | last post by:
A typical chunk of code...... Set db = CurrentDb Set rs = db.OpenRecordset("tblFoo") <Do some stuff here> 'How much of the stuff below do I need? 'Do I need to close the recordset? rs.Close
9
3928
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to...
1
7082
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that someone who bothers to read all of it have some pointers. Note, I have posted the stack trace and the code exhibiting the problem further down...
167
8198
by: darren | last post by:
Hi I have to write a multi-threaded program. I decided to take an OO approach to it. I had the idea to wrap up all of the thread functions in a mix-in class called Threadable. Then when an object should run in its own thread, it should implement this mix-in class. Does this sound like plausible design decision? I'm surprised that C++...
0
7527
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7967
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...
0
6052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5377
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
5097
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3505
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...
1
1953
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
1
1064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
772
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.