1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Single user, designing module, err: database has been placed in a state by user 'Admi

Discussion in 'MS Access' started by sharon7, Jul 20, 2012.

  1. sharon7

    sharon7 New Member

    Joined:
    Feb 23, 2012
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    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 :crazy:
     
    Last edited by a moderator: Jul 21, 2012

Share This Page