Closing recordset --> Subform becomes unbound

  • Thread starter Thread starter Lars Brownies
  • Start date Start date
L

Lars Brownies

In a module I have a function that loops through a subform's recordset. The
recordset is set as follows:

Dim rs As DAO.Recordset
Set rs = Forms![frmMain]![subfrmHypLink].Form.Recordset


After the loop I don't explicitly close the recordset but in the the
Exit_Handler I have:
Set rs = Nothing

This works well. However, I read that I should explicitly close the
recordset after using it. So at the end of the function (before the
exit_handler) I've put rs.close.

The strange thing now is that the subform becomes unbound when the recordset
is closed. Can someone explain what goes wrong here and how to solve it?

Thanks,

Lars
 
hi Lars,

Lars said:
The strange thing now is that the subform becomes unbound when the recordset
is closed. Can someone explain what goes wrong here and how to solve it?
You are closing the form's recordset. Use a copy (clone) of it:

Dim rs As DAO.Recordset
Set rs = Forms![frmMain]![subfrmHypLink].Form.Recordset.Clone
'..your logic
rs.Close
Set rs = Nothing


mfG
--> stefan <--
 
Thanks! I get it.
Lars

Stefan Hoffmann said:
hi Lars,

Lars said:
The strange thing now is that the subform becomes unbound when the
recordset is closed. Can someone explain what goes wrong here and how to
solve it?
You are closing the form's recordset. Use a copy (clone) of it:

Dim rs As DAO.Recordset
Set rs = Forms![frmMain]![subfrmHypLink].Form.Recordset.Clone
'..your logic
rs.Close
Set rs = Nothing


mfG
--> stefan <--
 
Back
Top