views:

28

answers:

2

In an MS-Access form, I have the following code attached to an event:

Dim frm As Form, rs As Recordset
Set rs = Me.RecordsetClone

'do some stuff with rs
'
rs.Close
Set rs = Nothing
Set frm = Nothing

My question is: is the rs.Close required ? Is it even good (undesired side effects ?)

+1  A: 

I don’t think the world would end but it is always good practice to close what you open.

Access used to have a problem where if you did not dispose of some object it would not quit but instead it would minimise to the task bar and you would have to kill the task. However as you are setting the object to nothing this would not affect you

Kevin Ross
My concern in the question is that we're talking here about a *clone*, which I understand as a pointer to another pre-existing object.
iDevlop
But he didn't open it -- the form's RecordsetClone already exists.
David-W-Fenton
A: 

No, the close is not required, and the simple rule is if your code did not open the reocrdset, then you don't want to close it. So, you only want/need to close things that you opended.

So, you are using a existing built in recordset, and you did not open that recordset. Setting both to nothing as you have is not required, but it can remain in place, and does show clear your intentions you done with the objects.

Albert D. Kallal