Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: Access Other topics FAQ

Access Howto:

Who has my database open? by FancyPrairie
Posted: 15 Apr 15

Prior to Access 2007 the workgroup file could be used to determine who was logged on to the database. Since Access 2007+ does not use the workgroup file, here's a function that will return a recordset of the names of the files that are open and the people that have the file open.

Note that it is assumed that the database is split between a front-end and back-end and the back-end resides on a shared server. Or the front-end references an Access database (i.e. library database) that resides on a shared server. If you pass the name of the computer in which the back-end db resides and (optionally) pass the name of the back-end database and someone has it open, this routine should return the name of the back-end db and the name of the user that has it open.

What this function does is returns the Open File and Accessed By columns as seen when you open the Computer Management form via the Administrative Tools via the Control Panel (System Tools | Shared Folders | Open Files)

Should work with Windows XP, 2000 and 2003.

CODE -->

Function GetOpenFiles(strComputerName As String, Optional strSearchForFile As String = "(ALL)") As ADODB.Recordset

    Dim objConnection As Object
    Dim colResources As Object
    Dim objResource As Object
    Dim strOutput As String

    Dim rst As New ADODB.Recordset

    rst.Fields.Append "OpenFile", adVarWChar, 255
    rst.Fields.Append "User", adVarWChar, 20

    Set objConnection = GetObject("WinNT://" & strComputerName & "/LanmanServer")   'You might need to check the registry for the name of the file service if not LanManServer
    Set colResources = objConnection.Resources
    On Error GoTo 7000
    For Each objResource In colResources
        If (strSearchForFile = "(ALL)") Or (InStr(objResource.Path, strSearchForFile) > 0) Then
            rst.Fields(0).value = objResource.Path
            rst.Fields(1).value = objResource.User
        End If

    rst.Sort = rst.Fields(0).Name & " ASC"
    Set GetOpenFiles = rst

End Function 

Here is an example of how to call the routine...

CODE -->

Dim rst as New ADODB.Recordset
Set rst = GetOpenFiles("NameOfTheComputer")
 (do whatever you want here)
set rst = nothing 

Back to Microsoft: Access Other topics FAQ Index
Back to Microsoft: Access Other topics Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close