how do I fix err: database has been placed in a state by user 'Admin

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sharonc
    New Member
    • Feb 2012
    • 2

    how do I fix err: database has been placed in a state by user 'Admin

    Hi,
    I have an MS Access 2010 database with a module called bas This module reads the fields on a Microsoft Word document and then the data is loaded to a linked SQL Server 2008 R2 table. I am currently desigining this module so I am the only user using this database. I open the MS Access database, open the code for the module and click on Debug>Run. I get the following error:
    -2147467259: The Database has been placed in a state by user ‘Admin’ on machine ‘JITC-PC’ that prevents it from being opened or locked.
    How do I get rid of this error? Does any one have a solution? I have searched the Internet all week but haven't found a solution that works.

    Here is my code:
    Code:
    Sub GetWordData()
        Dim appWord As Word.Application
        Dim doc As Word.Document
        Dim cnn As New ADODB.Connection
        Dim cnn2 As New ADODB.Connection
        Dim rst As New ADODB.Recordset
        Dim rst2 As New ADODB.Recordset
        Dim strDocName As String
        Dim blnQuitWord As Boolean
              
        On Error GoTo ErrorHandling
        
        strDocName = "\\JITC-PC\Users\Sharon\My Documents\GEOINT Repository\Requests\GEOINT_rep_req_form20111109 class.doc"
        Set appWord = GetObject(, "Word.Application")
        Set doc = appWord.Documents.Open(strDocName)
           
        cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=\\JITC-PC\Users\Sharon\Desktop\DEVELOPMENT.mdb"
    	
       
        ' Open Requester table to load
        rst.Open "dbo_Requester", cnn, adOpenKeyset, adLockOptimistic
         
        With rst
            .AddNew
            !Requester_Organization = doc.FormFields("Req_Org").result
        	.Update
            .Close
        End With 
    
         doc.Close
        
        If blnQuitWord Then appWord.Quit
            cnn.Close
            MsgBox "Requestor Data Imported!"
            
    Cleanup:
        Set rst = Nothing
        Set cnn = Nothing
        Set doc = Nothing
        Set appWord = Nothing
            
        Exit Sub
        
    ErrorHandling:
      Select Case Err
      Case -2147022986, 429
            Set appWord = CreateObject("Word.Application")
            blnQuitWord = True
            Resume Next
      Case 5121, 5174
            MsgBox "You must select a valid Word document. " _
                    & "No Data Imported.", vbOKOnly, _
                    "Word Document Not Found"
      Case 5941
            MsgBox "This Field is not found in the Word Document." _
                    & "No Data Imported.", vbOKOnly, _
                    "Fields not found in the Word Document"
      Case Else
            MsgBox Err & ": " & Err.Description
      End Select
      GoTo Cleanup
            
    End Sub
    Thank you for any help you can give me.

    Sharon Chapman
    Last edited by NeoPa; Jul 22 '12, 08:15 PM. Reason: Added the mandatory [CODE] tags for you.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Can you open DEVELOPMENT.mdb directly?
    IF so then make a backup of the file.

    Try a compact and repair...

    Which line is the error occuring?

    -z

    PS: your code should be inclosed in [CODE][/CODE] tags POSTING_GUIDELI NES: Please Read Carefully Before Posting to a Forum

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      something else to read: http://support.microsoft.com/kb/307640

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32645

        #4
        That error message means that the database is already open, and that whoever has it open is making design changes.

        Almost everyone is user 'Admin' as far as Access is concerned.

        In most cases, in the situation as you describe it, the other user is actually you. Either on the same PC or another one.

        Comment

        • dsatino
          Contributor
          • May 2010
          • 393

          #5
          As NeoPa said, the other user is usually you. That is the case here. When you open the db Access creates a lock file and that lock file is preventing you from doing what you are trying to do.

          The main problem is that you are trying to create a connection object to the db that you working in. You are already in the db, so why would you need to connect to it? Basically, you just need to open the recordset via a database object and use the .OpenRecordset method of that database object.

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            ADO Connection troubleshooting .

            Sorry, We've been on vacation, and still am :), and haven't had any real access ( access... funny... I do have a dry sense of humor... :) )) outside of dialup for the past week...

            SharonC:
            Working with NeoPa and Dsatino's posts and the fact that you mention an SQL server in your orginal post I now am not too sure as to what you have going here...

            From what I'm getting... it sounds like you have a front-end Access DB that is connecting to a back-end Access DB that is somehow linked to the SQL-Server mentioned in OP... is this correct? (and if so... like wow)

            Second, you have failed to mention at what point your code is generating the error. Without that information it is impossible to help you troubleshoot your code! NeoPa was good enough to wrap your code in the OP so you can refer to the point by line... I'm suspecting that this is happening at line 17???

            You may want to take a look at the following http://msdn.microsoft.com/en-us/library/ms807027.aspx and the related links therein... I have not worked enough with the ADO datatypes; however, working with the information in the links in my original replies and from Neo and Ds - I suspect that you're error may have to deal with connection.

            Best of luck and I hope to get back to regularly posting in the next week or so :-)

            -z

            Comment

            Working...