Results 1 to 3 of 3

Thread: Detecting an open recordset

  1. #1

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    How can I detect if a recordset is still open? Because in the Form_unload event I have it close all the recordsets, however if the recordset isn't open, then I get an error, so I want to check if it is open first. How can I do this? Thanks

    ------------------
    Ryan

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    If you use ADO, then it is very easy:

    Code:
    If rs.State = adStateClosed Then
        MsgBox "Recordset is closed."
    Elseif rs.State = adStateOpen Then
        MsgBox "Recordset is opened."
    End If
    ------------------

    Serge

    Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819


  3. #3
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232
    a recordset is Nothing when not open, so it's fairly simple (assume rstTmp is the recordset):

    Code:
    If rstTmp Is Nothing Then
      'do nothing
    Else
      'do something
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width