Results 1 to 14 of 14

Thread: Log Users

  1. #1
    New Lounger
    Join Date
    Feb 2001
    Location
    Sacramento, California, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Log Users

    Is there some way to create an external to Access file, or internal table, that logs access to a database? I would be interested in who is logging on and when, if that is possible. Is there some way to leverage the LDB file to do this, so that a log of users voer time can be developed?

    This would be a on a database with simple password security.

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    352
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Log Users

    This seems simple enough. Specify a form in Tools Startup in ADD mode. Get the user to enter username and password and bind the username field to a table. You could also include a date/time.

    Check the password and then close the box and open the first form you want the user to have access to.
    David Grugeon
    Brisbane Australia

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Log Users

    How about this one:
    Specify in the Startup dialog a form to start up with.
    Ensure the form keeps hidden.
    In the on load event of the form capture the username, preferebly the network user name, and write that with any information you want to an external file or a table.
    Put a timer on the form (1 second should be enough) and close the form with the timer.

  4. #4
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Altnau, Thurgau, Switzerland
    Posts
    447
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Log Users

    Are you interested in just when the user logs on or the duration of use of the DB? If you want the duration you may wish a hidden form that opens after start and uses the unload event to mark the session end.

  5. #5
    carl g.
    Guest

    Re: Log Users

    A tip is to use the Environ(argument as Integer) function:
    NTUser = Environ(9)

    Regards,

    Carl

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Log Users

    Yes, there's a way to get the NT User id (I'll dig the code out of one of my databases if you want it), but not by using environ(9). All eviron(9) gives me is "NUMBER_OF_PROCESSORS=1". I see from the on-line help that what environ(9) gives is simply the 9th string in the environment string table. Doesn't sound too reliable for getting something expected!

  7. #7
    carl g.
    Guest

    Re: Log Users

    Apologies!

    It works for me though (Access 97) - I suggest playing around with the integer that you pass to the Environ function (1- approx 15 from memory) - it reveals some interesting things.
    Here is the API (and my own function):

    Option Compare Database
    Option Explicit

    Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
    (ByVal lpBuffer As String, nSize As Long) As Long

    Public Function NTUSER()
    Dim sBuf As String
    sBuf = VBA.Space(40)
    GetUserName sBuf, 40
    NTUSER = VBA.left(sBuf, VBA.InStr(sBuf, VBA.Chr(0)) - 1)
    Debug.Print NTUSER
    End Function

    Regards,

    Carl

  8. #8
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Log Users

    I don't know where I got the following module, but it's worked for me with Access '97 and Windows '95 '98 and 2000 hope it's useful:
    Option Compare Database
    Option Explicit

    ' Objects for GetUserName_TSB()
    Declare Function TSB_API_GetUserName Lib "advapi32.dll" _
    Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As _
    Long) As Long

    Function GetUserName_TSB() As String
    ' Comments : Retrieves the name of the user logged into Windows
    ' Parameters: none
    ' Returns : string user name
    '
    Dim lngLen As Long
    Dim strBuf As String

    Const MaxUserName = 255

    strBuf = Space(MaxUserName)

    lngLen = MaxUserName

    If CBool(TSB_API_GetUserName(strBuf, lngLen)) Then

    GetUserName_TSB = Left$(strBuf, lngLen - 1)
    Else

    GetUserName_TSB = ""
    End If

    End Function

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Edmonton, Alberta, Canada
    Posts
    326
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Log Users

    Well, I eventually got to "USERNAME=DMartin" with environ(23) ! It does not look as though environ(number) is a very portable way to do anything, since it depends on a lot of things showing up in the same order every time.

  10. #10
    PatriciaWilliams
    Guest

    Re: Log Users

    I do this a lot -- I frequently have a "whosIn" table. What I do is pick up the environmental settings in the user's individual machine. For our network & software package uses, we have such things as "UserName" (really, initials), "FullName", and "Group", which were set up for various reasons over time. It's pretty easy to access anything you can view by typing "set" at the dos prompt (anybody ever go there anymore?). "environ$("USERNAME")" gives me what I want, (additionally, I have a date field with now() as a default). You might want to have some code to reduce the table every so often.
    thx
    Pat

  11. #11
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    The Netherlands
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Log Users

    And now the place where you can find the code to get the username: the good old Access Web of course!
    http://www.mvps.org/access/api/api0008.htm

  12. #12
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Log Users

    You got it from either the Total Access Sourcebook or the Total VB Sourcebook (or whatever they're calling the combined version now), which is available at a fairly steep price from FMS, Inc.
    Charlotte

  13. #13
    New Lounger
    Join Date
    Feb 2001
    Location
    Sacramento, California, USA
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Log Users

    Thank you, Grugeon, I used your suggestion and it is exactly what I needed. Very simple and straight forward.

  14. #14
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    352
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Log Users

    Pleased to have helped you.
    David Grugeon
    Brisbane Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •