Form_Close: Recordset Out Of Scope?

  • Thread starter (PeteCresswell)
  • Start date
P

(PeteCresswell)

In Form_Open, I'm creating a recordset.

That recordset is used successfully in various event functions
while the form is open.

In Form_Close, however, it seems like it does not exist when I go
to Close/Nothing it.

viz:
-------------------------------------------------------------------
Private Sub Form_Close()
debugStackPush Me.Name & ": Form_Close"
On Error GoTo Form_Close_err

' PURPOSE: - To clean up after ourselves table-wise
' - To save form's location so we can restore it next
' time

' Trapping out w/"3420: Object invalid or no longer set."

mIndexTableRS.Close
Set mIndexTableRS = Nothing

FormDimensions_Save Me, CurrentUserGet()

Form_Close_xit:
DebugStackPop
On Error Resume Next
Exit Sub

Form_Close_err:
BugAlert True, ""
Resume Form_Close_xit
End Sub
-------------------------------------------------------------------
 
A

Arvin Meyer [MVP]

Try closing the recordset in the error handler using a Case statement or If
.... Then construct to check for the existence of the recordset. If the
recordset has not been instantiated, you will always get an error.
 
P

(PeteCresswell)

Per Arvin Meyer [MVP]:
Try closing the recordset in the error handler using a Case statement or If
... Then construct to check for the existence of the recordset. If the
recordset has not been instantiated, you will always get an error.

No problem there.

If nothing else, I'll just wrap it in On Error Resume Next...

But what I'm wondering is whether it's even supposed tb there by
the time Form_Close fires.

I haven't done anything explicit (I hope....{fingers crossed..})
to close it.... yet it seems tb closed.

From context so far, I'd guess that it's not expected tb closed.
 
B

boblarson

Since the Close event is the last event, the recordset has already been
eliminated in the Unload event. You should use the form's UNLOAD event if
you want to do manipulation of the recordset before closing the form.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
If my post was helpful to you, please rate the post.
__________________________________
 

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