Robert
robert at servicexp.com
Fri Mar 21 17:09:23 CDT 2008
Hello Group,
I have a question about how to close an object correctly..
Dim rstWOS As DAO.Recordset
Set rstWOS = db.OpenRecordset("qryServicesNavigator", dbOpenDynaset,
dbInconsistent)
I do a findfirst on rstWOS which I pass to another form. Like such..
DoCmd.OpenForm "frmMsgboxWODelete", , , , , acHidden
With Form_frmMsgboxWODelete
.CallingForm = "Calander"
.RN = EventRN
Set .rst = rstWOS
.Visible = True
End With
In the form it's a property
Private m_objRst As DAO.Recordset
Public Property Set rst(objRst As DAO.Recordset)
Set m_objRst = objRst
End Property
Where do I Properly close and destroy the recordset, in the first or the
second or both?
I'm thinking that I need to destroy it on the first, as if I destroy it on
second via:
Private Sub Form_Unload(Cancel As Integer)
If Not m_objRst Is Nothing Then
m_objRst.Close
Set m_objRst = Nothing
End If
End Sub
Then I get some very strange problems trying to destroy in on the first..
Like and Error 3420 Oject Invalid or No Longer Set Via: (because the
recordset is already closed??)
If Not rstWOS Is Nothing Then
rstWOS.Close
Set rstWOS = Nothing
End If
TIA...
WBR
Robert