Use the Clone method to create multiple, duplicate Recordset objects, particularly if you want to be able to maintain more than one current record in a given set of records. Using the Clone method is more efficient than creating and opening a new Recordset object with the same definition as the original.
The current record of a newly created clone is set to the first record.
我也不知道是怎么回事情?郁闷。查閲了一下msdn:
Changes you make to one Recordset object are visible in all of its clones regardless of cursor type. However, once you execute Requery on the original Recordset, the clones will no longer be synchronized to the original.
Closing the original Recordset does not close its copies; nor does closing a copy close the original or any of the other copies.
You can only clone a Recordset object that supports bookmarks. Bookmark values are interchangeable; that is, a bookmark reference from one Recordset object refers to the same record in any of its clones.
再次查閲了clone原理之後,引用了博客園天伤之梦的一段話描述clone:获取浅表副本就是把这本书直接接给读者,获取深层副本就是把这本书留着(或者销毁),抄写一份给读者()。
代码:
Dim objPrv As Object 'SYSRRVB.clsPPrv
Dim objRectemp As New ADODB.Recordset
Dim objRectempcopy, Rectempcopy1 As New ADODB.Recordset
Dim strtemp
Set objPrv = CreateObject("'SYSRRVB.clsPPrv")
If Me.chkDep.Value = 1 Then
Set objRectemp = m_Buffer.Records(CLng(Mid(Trim$(Me.trvOrg.SelectedItem.Key), 2, 1)))
Set objRectempcopy= objRectemp .Clone
Set Rectempcopy1 = objRectemp
******
end if
clone的方法原理倒查閲了不少,但一直不知道爲什麽clone對象double原來的一倍?,而且增加的和原來的對象還不完全相同。?