Help !!! - Recordset set to Me.RecordsetClone

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi TWIMC

I have a query that is the record source of form. On the Form_Current event I set a recordset to Me.RecordSetClone see the following code. I've removed/commented out the rest of the code but problem still exists. Now the problem is for unknown reason if I close the Access session it re - opens and the only way to close the Access sesson is to use End Task
I've wittled it down to the code line Set rstMyRecords = Me.RecordsetClone in that if I comment this line and only declare the recordset and then set it to nothing everything is OK, so what is wrong with the line of code. I have other forms that do exactly the same. The only difference being the the record source for the other forms is normally just one table but for this form there are 4 tables and criteria which uses user defind functions not sure if this effects a recordset. Any ideas on why the Access session doesn't close would be much appriciated. I think something related to the recordset is obviously staying active and is not be released when either rstMyRecords.Closs or Set rstMyRecords = Nothing are being used

Private Sub Form_Current(
On Error GoTo Form_Current_Er
Dim rstMyRecords As DAO.Recordse

Set rstMyRecords = Me.RecordsetClon

Form_Current_Exit
On Error Resume Nex
rstMyRecords.Clos
Set rstMyRecords = Nothin
Exit Su

Form_Current_Err
MsgBox Err & ": " & Error$, vbCritical, "Form_frmAddEditData.Form_Current
Resume Form_Current_Exi
Resume Nex
Resum
End Su
 
Kevin-

Which version of Access? Which Service Pack level? There were known
problems like this with Access 97 - basically, VBA isn't shutting down - it
thinks there's still an active session with Access, so Access won't close,
either. (The clue about this recordset calling user functions is
significant.) But closing the recordset and setting it to Nothing should
disconnect it. Do any of the functions called from the recordset also open
recordsets? If so, do these functions properly close and set to Nothing?

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
Kevin McCartney said:
Hi TWIMC,

I have a query that is the record source of form. On the Form_Current
event I set a recordset to Me.RecordSetClone see the following code. I've
removed/commented out the rest of the code but problem still exists. Now the
problem is for unknown reason if I close the Access session it re - opens
and the only way to close the Access sesson is to use End Task.
I've wittled it down to the code line Set rstMyRecords = Me.RecordsetClone
in that if I comment this line and only declare the recordset and then set
it to nothing everything is OK, so what is wrong with the line of code. I
have other forms that do exactly the same. The only difference being the the
record source for the other forms is normally just one table but for this
form there are 4 tables and criteria which uses user defind functions not
sure if this effects a recordset. Any ideas on why the Access session
doesn't close would be much appriciated. I think something related to the
recordset is obviously staying active and is not be released when either
rstMyRecords.Closs or Set rstMyRecords = Nothing are being used.
 
Back
Top