Visual Basic Programming Code Examples Visual Basic > Database SQL Stuff Code Examples Cloning or copying an ADO recordset Cloning or copying an ADO recordset The code below shows how to copy/clone an existing ADO recordset. This functionality can be useful if you want to keep an copy of the data before the user makes any changes (note, you can also use the oRs.Fields(x).OriginalValue property for this). 'Purpose : Creates a copy an existing client side ADO recordset 'Inputs : oRs The recordset to copy 'Outputs : Returns a copy of the recordset on success, or nothing on failure. 'Notes : Function RsClone(oRs As ADODB.Recordset) As Recordset Dim oStream As ADODB.Stream, oRsClone As ADODB.Recordset On Error GoTo ErrFailed If oRs.CursorLocation = adUseClient Then Set oStream = New ADODB.Stream oRs.Save oStream, adPersistXML Set oRsClone = New ADODB.Recordset oRsClone.Open oStream Set oStream = Nothing Set RsClone = oRsClone Set oRsClone = Nothing Else Debug.Print "Must use client side recordsets..." Debug.Assert False End If Exit Function ErrFailed: Debug.Print Err.Description Debug.Assert False Set RsClone = Nothing End Function