Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a Recordset

Status
Not open for further replies.

Toga

Technical User
Jul 21, 2000
234
US
Before I close a recordset using rst.close, Is there a command I can use to tell if it is open first?

Thanks...Toga
 
If it's an ADO Recordset, you can use:

if rs.state = 1 then
rs.close
end if

adStateClosed = 0
adStateConnecting = 2
adStateExecuting = 4
adStateFetching = 8
adStateOpen = 1

These constant/enums can be used on connection objects, too.

:)
Paul Prewett
penny.gif
penny.gif
 
No...It's not ADO. I'm using the recordsets in Access 97.

The way I get around it now is by forcing an error if it's not open, setting a Status variable to true and then going on from there with resume next.....which just doesn't seem to be the right way to be doing things. Anyway, below is a little snippet of what I do.

Suggestions on how to do be doing this right are greatly appreciated.

MySub as Private ()
On Error GoTo ErrorHandler

If rstRunID.Bookmarkable Then 'Not true Produces an
If RstClosed <> True Then 'error
rstRunID.Close
End If
End If

Exit Sub
ErrorHandler:
Select Case Err.Number
Case 3420 'Object (Recordset) No longer set.
RstClosed = True
Resume Next
Case Else
MsgBox Err.Number & &quot; &quot; & Err.Description
End Select
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top