Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 80004005 Can't Open or Lock Database 1

Status
Not open for further replies.

pondside

Programmer
Jul 6, 2003
11
US
I just executed some new vba code, that somehow caused my database to freeze up. the full text of the message is:

Runtime error 80004005...

The database has been placed in a state by user ‘Admin’ on machine “Pondside” that prevents it from being opened or locked.

The relevant parts of the code are as follows:

Dim SQLString1 As String
Dim SQLString2 As String
Dim strSQL As String

Dim cnnct As ADODB.Connection
Dim rst1 As ADODB.Recordset
Dim rst2 As ADODB.Recordset

Set rst1 = New ADODB.Recordset
Set rst2 = New ADODB.Recordset

cnnct.ConnectionString = CurrentProject.Connection
cnnct.Open

SQLString1 = "SELECT * FROM tblAddressNew "
SQLString2 = "SELECT * FROM tblExamScores"
strSQL = "[lngDID] = " & ThisDID

rst1.ActiveConnection = CurrentProject.Connection
rst1.CursorType = adOpenStatic
rst1.Open SQLString1
rst1.Find strSQL

If not rst1.EOF Then
StartDate = Nz(rst1!START)
CompleteDate = Nz(rst1!COMPLETE)
End If

[etc.]....

rst1.Close
Set rst1 = Nothing
rst2.Close
Set rst2 = Nothing

cnnct.Close
Set cnnct = Nothing


What happened is that the first time through I had a misspelling in the IF clause, using "rst" instead of "rst1". Once I made the correction, I think I did a run reset without executing the closes. Now as soon as I hit the cnnct.Open statement I get the error. Apparently there's something I can do to correct the situation, but I am unclear what that something is.

A fast reply would be very helpful, as I am due to meet with the clients this in a couple of hours.
 
Re: The database has been placed in a state by user ‘Admin’ on machine “Pondside” that prevents it from being opened or locked.

Is this the machine you are developing on? Do you have any databases open where tables reside that are attached to your active mdb?
 
Yes, thanks for your reply. I am in fact running the database on Pondside computer, and I have no other databases.

Your question helped, by prompting me to look at other possibilities, and as I looked, I noticed an inconsistency within my code that seems to have triggered the error.

I was attempting to alter my code from a single recordset to a pair, and bringing in some "cookbook" code to alter the pre-exsting code. It seems I introduced the conflict by use of the new code which uses a connect string "cnnct" and cnnct.open. At the time I enter this code, I already have an active connection to the database on the invoking form, so perhaps this is the doubling up of connections to which the error refers. Does that make sense?

In any case, thaks for the reply, it helped me refocus!

Whether my interpretation is correct or not,
 
I've never tried to open simultaneous connections to the same database, but it sounds likely to have caused the error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top