Results 1 to 4 of 4
  1. #1
    Kaloyanides is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Location
    Arlington, MA
    Posts
    51

    Talking Logged On? How to show who's Logged On...

    I'm trying to get the following code to work in a multi user environment and with a split database.

    Any good programmers out there have a min to help me?

    I think it's just the first part that needs tweaking to point to the backend on the network drive?

    Location of backend = "\\10.1.10.54\Public\Database\Atlas v2_BE"

    Many thx in advance!!!

    Code:
    Private Function WhosOn() As String
    
    
       On Error GoTo Err_WhosOn
    
    
       Dim iLDBFile As Integer, iStart As Integer
       Dim iLOF As Integer, i As Integer
       Dim sPath As String, x As String
       Dim sLogStr As String, sLogins As String
       Dim sMach As String, sUser As String
       Dim rUser As UserRec   ' Defined in General
       Dim dbCurrent As Database
    
    
       ' Get Path of current database. Should substitute this code
       ' for an attached table path in a multi-user environment.
    
    
       Set dbCurrent = DBEngine.Workspaces(0).Databases(0)
       sPath = dbCurrent.Name
       dbCurrent.Close
    
    
       ' Iterate thru dbCurrent.LDB file for login names.
    
    
       sPath = Left(sPath, InStr(1, sPath, ".")) + "LDB"
    
    
       ' Test for valid file, else Error
    
    
       x = Dir(sPath)
       iStart = 1
       iLDBFile = FreeFile
    
    
       Open sPath For Binary Access Read Shared As iLDBFile
       iLOF = LOF(iLDBFile)
       Do While Not EOF(iLDBFile)
          Get iLDBFile, , rUser
          With rUser
             i = 1
             sMach = ""
             While .bMach(i) <> 0
                sMach = sMach & Chr(.bMach(i))
                i = i + 1
             Wend
             i = 1
             sUser = ""
             While .bUser(i) <> 0
                sUser = sUser & Chr(.bUser(i))
                i = i + 1
             Wend
          End With
          sLogStr = sMach & " -- " & sUser
          If InStr(sLogins, sLogStr) = 0 Then
             sLogins = sLogins & sLogStr & ";"
          End If
          iStart = iStart + 64   'increment to next record offset
       Loop
       Close iLDBFile
       WhosOn = sLogins
    
       Set dbCurrent = Nothing
    
    
    Exit_WhosOn:
       Exit Function
    
    
    Err_WhosOn:
       If Err = 68 Then
          MsgBox "Couldn't populate the list", 48, "No LDB File"
       Else
          MsgBox "Error: " & Err.Number & vbCrLf & Err.Description
          Close iLDBFile
       End If
       Resume Exit_WhosOn
    
    
    End Function

    Last edited by RuralGuy; 02-24-2018 at 08:50 AM. Reason: Added code tags and formatting

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    Watch this free video from Steve Bishop re User logins/logouts. He has other free videos that you might find useful.
    Since you mention who is logged on, I'm thinking you have a multi-user/split database situation.

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    First point is that the code is only for old MDB files with an LDB lock file
    It won't work on an ACCDB file with an LACCDB lock file

    I haven't looked at the code beyond that.
    However, I have a working example for both ACCDB & MDB files here: https://www.access-programmers.co.uk...d.php?t=295174
    See post #2 for the latest version
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    If this is important, then don't rely on a file that might not get removed from the network for any one of several reasons (and there are a few). If it's not important, don't bother with the login at all. The obvious conclusion then, is that if you're going to have a logged in count, use a process that reads a table in a back end db.

    There is a comment in the code after the declarations that makes me think your db is split, but everyone's using the same fe.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Logged In user Names
    By Parminder in forum Access
    Replies: 5
    Last Post: 07-23-2015, 02:17 PM
  2. logged in person on all forms?
    By ariansman in forum Forms
    Replies: 3
    Last Post: 02-27-2015, 09:19 AM
  3. Who Logged In
    By CementCarver in forum Programming
    Replies: 5
    Last Post: 06-28-2013, 10:30 AM
  4. who's logged in
    By slimjen in forum Forms
    Replies: 2
    Last Post: 03-26-2013, 01:27 PM
  5. Whos Logged in????????
    By george.vniekerk in forum Security
    Replies: 2
    Last Post: 08-26-2011, 12:24 PM

Tags for this Thread

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