Possible to work with a true stand alone clone of a forms recordset?

  • Thread starter Thread starter Jeremy Gollehon
  • Start date Start date
J

Jeremy Gollehon

How can I get a copy of a forms RecordSet that isn't affected when the form
is requeried?
I thought the following (using ByVal) was my best hope but it didn't work.

---------------------------------------------------------------------
Private mRecordsetB4Requery As DAO.Recordset

Public Property Get RecordsetB4Requery() As DAO.Recordset
Set RecordsetB4Requery = mRecordsetB4Requery
End Property

Public Property Set RecordsetB4Requery(ByVal rsRecordsetB4Requery As
DAO.Recordset)
Set mRecordsetB4Requery = rsRecordsetB4Requery
End Property

Private Sub Form_Open(Cancel As Integer)
Set Me.RecordsetB4Requery = Me.RecordsetClone
End Sub
---------------------------------------------------------------------

References to Me.RecordsetB4Requery work exactly like a reference to
Me.RecordSetClone until the form is requeried then I get Error 91: Object
variable or With block variable not set.

Thanks for any ideas,
Jeremy
 
Well, figured this one out on my own. The help file for RecordsetClone was
a little confusing. It states, "The RecordsetClone property setting is a
copy of the underlying query or table specified by the form's RecordSource
property." The keyword for me was *copy*. In reality it's just a pointer
back to the RecordSet of the form. If a variable is set to
Me.RecordsetClone and the form is requeried, the variable is destroyed.

What I was really looking for is Recordset.Clone. The help file (DAO
version) for the Clone property states, "Use the Clone method to create
multiple, duplicate Recordset objects." *Multiple, duplicate* being the
keywords here.

My previous code simplifies to:
-----------------------------------------------------------------------
Private RecordsetB4Requery As DAO.Recordset

Private Sub Form_Open(Cancel As Integer)
Set RecordsetB4Requery = Me.Recordset.Clone
End Sub
 
Back
Top