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.openrecordse t("qryStudentsS orted").
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.OpenRecordse t("qryStudentsS orted")
' 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