By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

what does Set rst = nothing mean and others

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.