Results 1 to 4 of 4

Thread: How to check if a recordset is opened ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Resolved How to check if a recordset is opened ?

    I have declare a recordset

    VB Code:
    1. public rs as new ADODB.recordset

    It is used in many functions that I have in my form.

    However sometimes, I encounter problem when I try to open it again as it says it is already opened. Reason because I allow the user to break the loop and exit function hence, sometimes the recordset is not closed.

    Question : How can I check if a particular recordset is already opened ?
    If I can check if it is opened then I can do a rs.close which will solve my problem.

    Anyone with solution please help !!!
    Last edited by icongroup2003; Jan 7th, 2005 at 03:43 AM.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: How to check if a recordset is opened ?

    When the loop is exited close the recordset.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: How to check if a recordset is opened ?

    My function is complex .... I know that by exiting the loop I can close it, however, when the user break the loop .... it can sometimes bypass the recordset.close

    Again, once the recordset is closed, it cannot be close again. A error will be prompted.

    Also, is there a way to turn off error messages in VB6 ?

    Sometime like in access where you can docmd.setwarnings = false ...

    but in VB6 you cannot ....

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Resolved Re: How to check if a recordset is opened ?

    Ok problem solved.


    Apparaently, there is a property .state which allow me to check if it is opened or not.

    VB Code:
    1. if rs.state = adStateOpen then rs.close

    That solved my problem.

    Cheers !!!

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