开发者

MS Access: .Close required after .RecordSetClone?

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

'd开发者_运维百科o 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 ?)


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜