Go4Expert (http://www.go4expert.com/)
-   MS Access (http://www.go4expert.com/forums/ms-access-forum/)
-   -   Single user, designing module, err: database has been placed in a state by user 'Admi (http://www.go4expert.com/forums/single-user-designing-module-err-t28764/)

sharon7 21Jul2012 01:56

Single user, designing module, err: database has been placed in a state by user 'Admi
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:


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
        !Requester_Organization = doc.FormFields("Req_Org").result
    End With

    If blnQuitWord Then appWord.Quit
        MsgBox "Requestor Data Imported!"
    Set rst = Nothing
    Set cnn = Nothing
    Set doc = Nothing
    Set appWord = Nothing
    Exit Sub
  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:

All times are GMT +5.5. The time now is 12:11.