By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,660 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,660 IT Pros & Developers. It's quick & easy.

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

P: 2
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:
Expand|Select|Wrap|Line Numbers
  1. Sub GetWordData()
  2.     Dim appWord As Word.Application
  3.     Dim doc As Word.Document
  4.     Dim cnn As New ADODB.Connection
  5.     Dim cnn2 As New ADODB.Connection
  6.     Dim rst As New ADODB.Recordset
  7.     Dim rst2 As New ADODB.Recordset
  8.     Dim strDocName As String
  9.     Dim blnQuitWord As Boolean
  10.  
  11.     On Error GoTo ErrorHandling
  12.  
  13.     strDocName = "\\JITC-PC\Users\Sharon\My Documents\GEOINT Repository\Requests\GEOINT_rep_req_form20111109 class.doc"
  14.     Set appWord = GetObject(, "Word.Application")
  15.     Set doc = appWord.Documents.Open(strDocName)
  16.  
  17.     cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  18.         "Data Source=\\JITC-PC\Users\Sharon\Desktop\DEVELOPMENT.mdb"
  19.  
  20.  
  21.     ' Open Requester table to load
  22.     rst.Open "dbo_Requester", cnn, adOpenKeyset, adLockOptimistic
  23.  
  24.     With rst
  25.         .AddNew
  26.         !Requester_Organization = doc.FormFields("Req_Org").result
  27.         .Update
  28.         .Close
  29.     End With 
  30.  
  31.      doc.Close
  32.  
  33.     If blnQuitWord Then appWord.Quit
  34.         cnn.Close
  35.         MsgBox "Requestor Data Imported!"
  36.  
  37. Cleanup:
  38.     Set rst = Nothing
  39.     Set cnn = Nothing
  40.     Set doc = Nothing
  41.     Set appWord = Nothing
  42.  
  43.     Exit Sub
  44.  
  45. ErrorHandling:
  46.   Select Case Err
  47.   Case -2147022986, 429
  48.         Set appWord = CreateObject("Word.Application")
  49.         blnQuitWord = True
  50.         Resume Next
  51.   Case 5121, 5174
  52.         MsgBox "You must select a valid Word document. " _
  53.                 & "No Data Imported.", vbOKOnly, _
  54.                 "Word Document Not Found"
  55.   Case 5941
  56.         MsgBox "This Field is not found in the Word Document." _
  57.                 & "No Data Imported.", vbOKOnly, _
  58.                 "Fields not found in the Word Document"
  59.   Case Else
  60.         MsgBox Err & ": " & Err.Description
  61.   End Select
  62.   GoTo Cleanup
  63.  
  64. End Sub
Thank you for any help you can give me.

Sharon Chapman
Jul 20 '12 #1
Share this Question
Share on Google+
5 Replies


zmbd
Expert Mod 5K+
P: 5,397
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_GUIDELINES: Please Read Carefully Before Posting to a Forum
Jul 20 '12 #2

zmbd
Expert Mod 5K+
P: 5,397
something else to read: http://support.microsoft.com/kb/307640
Jul 20 '12 #3

NeoPa
Expert Mod 15k+
P: 31,487
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.
Jul 22 '12 #4

dsatino
100+
P: 393
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.
Jul 23 '12 #5

zmbd
Expert Mod 5K+
P: 5,397
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
Jul 31 '12 #6

Post your reply

Sign in to post your reply or Sign up for a free account.