Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / October 2007

Tip: Looking for answers? Try searching our database.

login id

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fredloh@gmail.com - 30 Oct 2007 16:52 GMT
when user level security is implemented, is there anyway i can
programmatically retrieve the login id of the user who has just logged
in?
Patrick A - 30 Oct 2007 21:49 GMT
I found this code (Dev's?) for a module in an earlier post sometime in
the last month...

It works like a charm.  It writes the Windows Login ID nicely.

The way I am using it is to call the code from a form where the user
is changing data.  I then write the value (via a hidden text box) to a
record-level field.

_______________________________________________________________________________________

Option Explicit

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

   Dim iStringLength As Long, i As Long
   Dim sString As String

   sString = String(255, 0)

   iStringLength = Len(sString)
   sString = Space$(iStringLength)

   If WinAPI_GetUserName(sString, iStringLength) Then
       i = InStr(sString, Chr(0))
       If i Then
           sString = Left(sString, i - 1)
       End If
       NetworkUserName = Trim(Left$(sString, iStringLength))
   Else
       NetworkUserName = "Unknown"
   End If

End Function
Keith Wilby - 31 Oct 2007 09:09 GMT
>I found this code (Dev's?) for a module in an earlier post sometime in
> the last month...

... and if you want the user's database ID use the CurrentUser function.

Keith.
www.keithwilby.com
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.