Closing recordset --> Subform becomes unbound

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
 
S

Stefan Hoffmann

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 <--
 
L

Lars Brownies

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 <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top