Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Question Unanswered: How to find the Status of Recordset in DAO 3.6?

    Hi all
    in ado we can make this function to close the recordset

    if rs.status<>adStateClosed then
    rs.close
    set rs=Nothing
    Endif


    How to make the same function with DAO3.6 or any DAO?
    I want to find out the status of the recordset first , close it only if its open .
    Thanx in Advance

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I always use

    Set rst = Nothing

    That will close the DAO recordset if it's open, and ignore it if not.

  3. #3
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: How to find the Status of Recordset in DAO 3.6?

    [QUOTE][SIZE=1]Originally posted by VBAPROGRAMMER
    Thanx for your response.
    No I just tested it out again. It gives an error message if the recordset its not open.
    I am working on huge project where i have to deal with lots of recordsets . So i want to make a function to pass the recordset and close it if its open in DAO.
    I dont see any property or method with DAO recordset to achieve this task.
    Any Other ideas?
    thanx in advance.

  4. #4
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    The only other thing I can think of is to try to trap the error

    ....
    On error goto ERRCLOSED
    rst.close
    ...

    ERRCLOSED:
    If err=91 then '91 should be the error number returned in this case
    Resume Next
    Else
    ...
    End if

  5. #5
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: How to find the Status of Recordset in DAO 3.6?

    [QUOTE][SIZE=1]Originally posted by VBAPROGRAMMER
    thanx for ur reply , What You Gurus Think of this Solution?

    Public Function CloseRecordset(Recordset As Recordset)
    If TypeName(Recordset) = "Recordset" Then
    If Not IsEmpty(Recordset) Then
    Recordset.Close
    Set Recordset = Nothing
    End If
    End If
    End Function

    any ideas?
    Thanx in advance

  6. #6
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Re: How to find the Status of Recordset in DAO 3.6?

    [QUOTE][SIZE=1]Originally posted by VBAPROGRAMMER
    RedNeck ...Error Trapping in this case sounds very good and most Appropriate solution. Here is the new code. Need ur feed back on this , would appreciate that

    On Error GoTo CloseRecordset_Err_Handler
    If TypeName(Recordset) = "Recordset" Then
    If Not IsEmpty(Recordset) Then
    Recordset.Close
    Set Recordset = Nothing
    End If
    End If
    Exit Function
    CloseRecordset_Err_Handler:
    If Err = 91 Then
    Resume Next
    Else
    MsgBox Err.Number & " " & Err.Description & " " & Err.Source
    Err.Close
    Exit Function
    End Function

  7. #7
    Join Date
    Nov 2002
    Location
    Hamilton,Ontario
    Posts
    132

    Thank You So Much For Your Help Redneck

    [QUOTE][SIZE=1]Originally posted by VBAPROGRAMMER
    really Appreciate ur ideas and help Redneck ,Thanx

Posting Permissions

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