Getting PC Identification

mutrus

Board Regular
Joined
Sep 10, 2002
Messages
80
I have a routine in my database that logs and stores the time users open the application and the names of the users (name is derived from a Log In procedure).

I would also like to be able to also log the name of the PC that the user has used to log in with. I have seen routines that can extract the data from the LDB file but so far I have been unable to associate this with the actual logged in user.

Is there any way that this can be done. Knowing the precise time that the user logged into the database can this then be associated with the PC name in the LDB file or is there another way

Thanks

Rick
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
This works under A97/W2k I have not tested with any other combinations but will probably work.

Sub temp()
Dim strUser As String
Dim strPC As String

strUser = Environ("USERNAME")
strPC = Environ("COMPUTERNAME")

MsgBox (strUser & " is on PC " & strPC)
End Sub


Peter
 
Upvote 0
I like bat's Environ usage. Hadn't really considered it for username because I had the API call handy.

Code:
Public Declare Function apiGetUserName Lib "advapi32.dll" Alias _
    "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

 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
'


Public Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
    strUserName = String$(254, 0)
    lngLen = 255
    lngX = apiGetUserName(strUserName, lngLen)
    If (lngX > 0) Then
        fOSUserName = Left$(strUserName, lngLen - 1)
    Else
        fOSUserName = vbNullString
    End If

    If Len(fOSUserName) = 0 Then
      MsgBox "Please set your userid under the Tools-Options-General Tab"
    End If

End Function

Take a peek at this index for a variety of other things to use.
I believe the above needs a reference to MS Office Scripting Runtime to work.

Here's current computer name:
http://www.mvps.org/access/api/api0009.htm

This is a link to a database launcher utility that goes into the lockfile (ldb) to extract information. Good proof of concept to use as a sample to work out what you need.

http://www.fabalou.com/FullPrograms/Dblauncher.asp

Mike
 
Upvote 0

Forum statistics

Threads
1,221,773
Messages
6,161,855
Members
451,724
Latest member
sledparty

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top