473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

what does Set rst = nothing mean and others

Sorry I just lost tracks of a series of posts, so I post my question again,
hoping someone can help.

Here is codes provided by Jeff Smith
Private Sub Form_Load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim intI As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("qryStudentsSorted")
' Call the routine to clear all fields
' before loading the data.
ClearFields
' Add the StudentName to each text box.
With rst
.MoveFirst
Do Until .EOF Or intI = txtMax
intI = intI + 1
Me("txt" & intI) = !StudentName
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub

Can anyone tell me: why need "Call the routine to clear all fields before
loading the data"? and

what do these three lines mean?
rst.Close
Set rst = Nothing
Set db = Nothing


Many thanks in advance.

Paul


Nov 13 '05 #1
2 10330
That first line is just a comment to the people who wrote or look at
the code to help them figure out what they were doing (or what the
code does). Just as it says, the routine (ClearFields) is called
which clears the fields.

rst.close is closing the recordset, which was open with the line
set rst = db.openrecordset("qryStudentsSorted").

If you open a recordset, you need to close it. Less objects open
saves memory and makes your program run faster. Note: some queries
run (such as delete queries) don't need to be closed after they are
opened.

the last two lines just empty the values in those variables. I know
there is a good reason for doing so, mostly I think because of the
variables/objects and garbage collection and memory leaks.

"Paul T. Rong" <et***@hotmail.com> wrote in message news:<yh*****************@news.chello.at>...
Sorry I just lost tracks of a series of posts, so I post my question again,
hoping someone can help.

Here is codes provided by Jeff Smith
Private Sub Form_Load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim intI As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("qryStudentsSorted")
' Call the routine to clear all fields
' before loading the data.
ClearFields
' Add the StudentName to each text box.
With rst
.MoveFirst
Do Until .EOF Or intI = txtMax
intI = intI + 1
Me("txt" & intI) = !StudentName
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub

Can anyone tell me: why need "Call the routine to clear all fields before
loading the data"? and

what do these three lines mean?
rst.Close
Set rst = Nothing
Set db = Nothing


Many thanks in advance.

Paul

Nov 13 '05 #2
Thank you, that makes sense.

"user_5701" <us*******@hotmail.com>
??????:f1**************************@posting.google .com...
That first line is just a comment to the people who wrote or look at
the code to help them figure out what they were doing (or what the
code does). Just as it says, the routine (ClearFields) is called
which clears the fields.

rst.close is closing the recordset, which was open with the line
set rst = db.openrecordset("qryStudentsSorted").

If you open a recordset, you need to close it. Less objects open
saves memory and makes your program run faster. Note: some queries
run (such as delete queries) don't need to be closed after they are
opened.

the last two lines just empty the values in those variables. I know
there is a good reason for doing so, mostly I think because of the
variables/objects and garbage collection and memory leaks.

"Paul T. Rong" <et***@hotmail.com> wrote in message

news:<yh*****************@news.chello.at>...
Sorry I just lost tracks of a series of posts, so I post my question again, hoping someone can help.

Here is codes provided by Jeff Smith
Private Sub Form_Load()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim intI As Integer
Set db = CurrentDb
Set rst = db.OpenRecordset("qryStudentsSorted")
' Call the routine to clear all fields
' before loading the data.
ClearFields
' Add the StudentName to each text box.
With rst
.MoveFirst
Do Until .EOF Or intI = txtMax
intI = intI + 1
Me("txt" & intI) = !StudentName
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub

Can anyone tell me: why need "Call the routine to clear all fields before loading the data"? and

what do these three lines mean?
rst.Close
Set rst = Nothing
Set db = Nothing


Many thanks in advance.

Paul

Nov 13 '05 #3

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

Similar topics

0
by: Andrey Mishenin | last post by:
While accessing MySQl data base by means of perl the value of variable $! sometimes equals " Resource temporarily unavailable". At the mean time everything works correct. What does that mean?...
4
by: David | last post by:
Hi, Buddy, a newbie's question for you guys, In C++, some functions have a return value type "result", what does this mean, I searched on web, but no hint. thanks a lot David
4
by: pete | last post by:
I found it in the view source of a corporate website. <script Language="Javascript"> <!-- var keyMacro= ]; //--> </script>
6
by: **Developer** | last post by:
What does this mean: External component has thrown an exception. My program crashes after it leaves a subroutine. What I see during debugging is when I press F11 at the End Sub statement
7
by: Jake Thompson | last post by:
What does SIMENTRY mean as in ULONG SIMENTRY RemoveFolderItem( hSession, pszFolderID, pszItemID, pAsyncCtl, pRC ) is it necessary?
9
by: JoeC | last post by:
m_iWidth = (int)pBitmapInfo->bmiHeader.biWidth; m_iHeight = (int)pBitmapInfo->bmiHeader.biHeight; What does this mean? I have seen v=&var->member.thing; but what does it mean when you...
6
by: Bint | last post by:
I'm getting this returned from a PHP script. What does this mean? <b>Parse error</b>: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in <b>/ho Thanks B
0
by: steve | last post by:
What does it mean to set a value or April fools all year long :) http://beyondsql.blogspot.com/2008/03/sql-what-does-it-mean-to-set-value.html
1
by: rasmidas | last post by:
Hi, Could anyone please let me know what does it mean by the following statement in solaris shell scripting. $PROMPT " Select an option: " read ans db_option=${ans:=0} I...
8
by: Ariel White | last post by:
What does it mean to pass data by value and how does that compare to passing data by reference? Please explain to me why we would pass some data by value and others by reference.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...

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.