Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2011
    Posts
    12

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

    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:


    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

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    You declare cnn as connection and rst as recordset variables but don't set them before trying to Open them.

    Is DEVELOPMENT.mdb the project this code is in? If so, the cnn.Open is not needed. Try:

    Set cnn = CurrentProject.Connection
    Set rst = New ADODB.Recordset

    Or instead of all the connection and recordset code try SQL action:

    CurrentDb.Execute "INSERT INTO tablename(Requester_Organization) VALUES('" & doc.FormFields("Req_Org").result & "'")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 11-18-2013, 02:20 PM
  2. Split Database only allowing single user access
    By terricritch in forum Database Design
    Replies: 2
    Last Post: 11-08-2011, 11:12 PM
  3. Replies: 3
    Last Post: 09-22-2011, 03:35 PM
  4. Replies: 1
    Last Post: 08-25-2011, 11:41 AM
  5. Replies: 8
    Last Post: 06-30-2010, 10:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums