who logged in

  • Thread starter Thread starter Guest
  • Start date Start date
sherwin verdun said:
i wanted to know who logged in into the database for access 2003. any help?

The simplest method IMO is to use the "Environ" property. This is frowned
upon by many developers because the property can be modified by savvy users,
but you have to ask yourself how likely is that to happen in your domain.

Regards,
Keith.
www.keithwilby.com
 
Keith Wilby said:
The simplest method IMO is to use the "Environ" property. This is frowned
upon by many developers because the property can be modified by savvy
users, but you have to ask yourself how likely is that to happen in your
domain.

I read this as a request to know, at a given point in time, how many users
were using a particular database.

If I'm correct, the answer is in
http://search.support.microsoft.com/kb/285822/

As to using the Environ property to get the user id of the current user,
while I agree that the possibility of abusing it is remote, using the API
call is pretty simple, so I don't understand not doing it correctly. <g>
http://www.mvps.org/access/api/api0008.htm
 
This is copied from a forgotten source, but works for me.

Create a tblLogin to hold the LoginName and LoginDateTime.

Run this update query each time the application is started:

INSERT INTO TblLogin ( LoginName, LoginDateTime )
VALUES (fOSMachineName(), Now());

Include this code in any global module:

Function fOSMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
fOSMachineName = Left$(strCompName, lngLen)
Else
fOSMachineName = ""
End If
End Function

-Ed
 
Your code sample is incomplete: it's missing the declaration of
apiGetComputerName, which is:

Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

That must be put at the beginning of the same module where you've placed
fOSMachineName.

BTW, that code came from http://www.mvps.org/access/api/api0009.htm at "The
Access Web". You obviously chose to ignore the copyright information when
you copied it!

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
 
Thanks for the correction.

-Ed

Douglas J. Steele said:
Your code sample is incomplete: it's missing the declaration of
apiGetComputerName, which is:

Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

That must be put at the beginning of the same module where you've placed
fOSMachineName.

BTW, that code came from http://www.mvps.org/access/api/api0009.htm at
"The Access Web". You obviously chose to ignore the copyright information
when you copied it!

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top