Link to home
Start Free TrialLog in
Avatar of akeith
akeith

asked on

Access Won't Open Files on Windows 2003 R2

Access won't open databases that have a lock file.  The database opens fine on other OS versions.
Avatar of RgGray3
RgGray3

Sounds like someone has their installation of access set to "Open Exclusive"  (Not playing nicely with others)

try placing  the following block of code in a new database and seperate Code Module



Option Compare Database

Public Function ADOShowUserRosterToString(cnnConnection As ADODB.Connection) As String
Dim rstTmp As New ADODB.Recordset
Dim strTmp As String
 
    ' This is the value to pass to Jet to get the
    ' user roster back.
    Const cstrJetUserRosterGUID As String = _
     "{947bb102-5d43-11d1-bdbf-00c04fb92675}"
   
    On Error GoTo PROC_ERR
   
    ' Jet exposes the user roster as a provider-specific schema
    ' rowset. To get Jet to return this, we open a recordset
    ' and pass the special GUID value.
    Set rstTmp = cnnConnection.OpenSchema( _
    adSchemaProviderSpecific, , cstrJetUserRosterGUID)
    ' The recorset contains four fields:
    ' COMPUTER_NAME: the machine name of the user's computer
    ' LOGIN_NAME : the name the user logged into Access with
    ' CONNECTED : True if the user is still connected
    ' SUSPECT_STATE: Connection was terminated normally or not (generally returns Nothing
    ' if the user terminated normally or is still in the database)
    '
    With rstTmp
        Do Until .EOF
            strTmp = strTmp & _
            .Fields(0).Name & ":" & Trim(.Fields(0).Value) & ", " & _
            .Fields(1).Name & ":" & Trim(.Fields(1).Value) & ", " & _
            .Fields(2).Name & ":" & Trim(.Fields(2).Value) & ", " & _
            .Fields(3).Name & ":" & Trim(.Fields(3).Value) & vbCrLf
            .MoveNext
        Loop
    End With
   
    rstTmp.Close
   
    ADOShowUserRosterToString = strTmp
   
PROC_EXIT:
    Exit Function
   
PROC_ERR:
    MsgBox "Error: " & err.Number & ". " & err.Description, , _
     "ADOShowUserRosterToString"
    Resume PROC_EXIT
End Function

Public Sub TestUserRosterRoutine()
'************ Begin Example Code ************
' To call the above function, all you need to do is open
' connection to the database. This example code will
' show the connection you create in code here, as well as
' any other users in the database.'
 Dim cn As ADODB.Connection
 Set cn = New ADODB.Connection
 ' Open the connection
 With cn
   .CursorLocation = adUseServer
   .Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\ThePath\ToYour\Database.mdb"
 End With '

  'Example code for ADOShowUserRosterToString
  Debug.Print ADOShowUserRosterToString(cn)
 
'************ End Example Code ************"

End Sub


Replace the line ...    Data Source=C:\ThePath\ToYour\Database.mdb"  with ThePathToYourDatabaseThatIsLocked
and run the TestUserRosterRoutine

It should tell you who the offending user and machine is...

Rich

Avatar of akeith

ASKER

How come I can still open it on XP and 2000 but not 2003?  Is there something I can do to Windows 2003 to open it anyway?
First, what version of access,
Second...   did you run the code to see if the database is in use by others..
third...   If the file is on a different server...  check to make sure you have permissions on that server...

Rich
Avatar of akeith

ASKER

Office 2003 SP 2

I can open it fine if there's no lock.  When there's a lock file present Windows doesn't even launch Access and shows no error messages.  The lock file goes away the file opens fine.
OK ...

Someone is probably oppening the file with sharing option set to EXCLUSIVE  instead of SHARED

The following is from Access help
----------------------------------------------------------------------------------
On the Tools menu, click Options.

Click the Advanced tab.
Do one or more of the following:
Specify whether a Microsoft Access database opens in shared or exclusive mode by default

Under Default open mode, do one of the following:
If you want others to be able to open the Microsoft Access database (Microsoft Access database: A collection of data and objects (such as tables, queries, or forms) that is related to a particular topic or purpose. The Microsoft Jet database engine manages the data.) at the same time you have it open, click Shared.

If you want sole access to the Access database when you have it open, click Exclusive.

---------------------------------------------------------------------------

It is my belief that someone has oppened the database in exclusive mode

If you simply double click on the MDB file, AND your defalt open shared mode is set to exclusive...  guess what....  

Create an empty database
Paste the code I posted into a new module and run the test routine

Rich
Avatar of akeith

ASKER

When I run that code I get

Runtime error '-2147217843 (80040e4d)':
Cannot start you application. The workgroup information file is missing or opened exclusively by another user.

I never doubted it was opened exclusively, but how come I can open it with XP but not Windows 2003?
ASKER CERTIFIED SOLUTION
Avatar of RgGray3
RgGray3

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial