469,917 Members | 1,825 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

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 9681
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by David | last post: by
4 posts views Thread by pete | last post: by
7 posts views Thread by Jake Thompson | last post: by
9 posts views Thread by JoeC | last post: by
6 posts views Thread by Bint | last post: by
reply views Thread by steve | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.