Polling Internal user account using VB

R

requeth

Hello,

I currently have a database that has two types of users built in (using
the access system). Only two actual usernames are created of "admin"
and "user". I also have a module that polls the operating system to get
the windows user, as well as time, and date. Since multiple people will
have access to the admin user, I would like to log the login type to my
login log. How would I poll the access username? If it helps I attached
my module code below.

Option Compare Database

Public Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
Dim v_user As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
GetUserName = Left$(strUserName, lngLen - 1)
Else
GetUserName = ""
End If
v_user = GetUserName
sqlInsertStatement = "Insert into
UserLog([UserName],[LoginDate],[LoginTime]) Values('" & v_user & "','"
& Format(Date, "mm\/dd\/yyyy") & "','" & Time & "')"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlInsertStatement
DoCmd.SetWarnings True
End Function
 
J

Joan Wild

Hello,

I currently have a database that has two types of users built in
(using the access system). Only two actual usernames are created of
"admin" and "user". I also have a module that polls the operating
system to get the windows user, as well as time, and date. Since
multiple people will have access to the admin user, I would like to
log the login type to my login log. How would I poll the access
username?

Use the CurrentUser() function.
 

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

Similar Threads

Using the API call for the current username 0
Troubleshooting Logging module 2
Cryptic compile error 6
Capitalise 6
Update form field 2
Update username 8
Porting from 2003 to 2007 6
Another audit Trail module 8

Top