Results 1 to 5 of 5

Thread: Runtime error 3705 & 3704 / msdn no help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    243

    Runtime error 3705 & 3704 / msdn no help

    I am getting two different runtime errors that I cannot figure out. I origionally didn't have the Rs.close in this code but I put it there hopeing to fix the error. But I have had no luck in trying to figure this out. I also tried the suggestions at MSDN, http://support.microsoft.com/defaul...kb;en-us;275927, but that hasn't worked either.

    Any suggestions?? Many thanks.

    visual basic code:'change query to select all buildings
    'Rs.Close
    strsql = "select bldg from bldgtype where type = 1 order by bldg"
    Rs.Open strsql, Db




    Run-time error: '3705': Operation is not allowed when the object is open.


    visual basic code:'change query to select all buildings
    Rs.Close
    strsql = "select bldg from bldgtype where type = 1 order by bldg"
    Rs.Open strsql, Db



    Run-time error: '3704': Operation is not allowed when the object is closed.

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Runtime error 3705 & 3704 / msdn no help

    you could try to completely get rid of it...

    rs.close
    set rs = nothing

    set rs = new adodb.recordset

    strsql = "select bldg from bldgtype where type = 1 order by bldg"
    Rs.Open strsql, Db

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    243

    Re: Runtime error 3705 & 3704 / msdn no help

    Thank you!!!

    VB Code:
    1. Set Rs = Nothing
    2.        
    3.         Set Rs = New ADODB.Recordset
    4.        
    5.         strsql = "select bldg from bldgtype where type = 1 order by bldg"
    6.         Rs.Open strsql, Db

    Works perfectly!!!

  4. #4
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    Re: Runtime error 3705 & 3704 / msdn no help

    No problemo. Glad to help.

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Runtime error 3705 & 3704 / msdn no help

    IMHO, it is better to "close" objects properly, rather than abruptly ending the instance by setting it to nothing. If an object has a Close method, call it.

    Based on the information it looks like you are calling this procedure multiple times. Just check the state of the rs object and act accordingly.

    VB Code:
    1. If rs is Nothing then
    2.    Set rs = New ADODB.Recordset
    3. End If
    4.  
    5. If rs.State = adStateOpen then
    6.    rs.Close
    7. End If
    8.  
    9. strsql = "select bldg from bldgtype where type = 1 order by bldg"
    10.  
    11. Rs.Open strsql, Db

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