Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Check User ID 2

Status
Not open for further replies.

sandra45

Technical User
Apr 3, 2003
72
ID
Hi, I want to write code in Access that can check the user name logging on to the system. Therefore, no matter where the user will log on in LAN (any computer he/she uses), I can still retrieve his/her ID and send him/her appropriate message. Can anyone inform me about the coding? Thanks.

Sandra
 
Below is the code that I use in a module. If you want the MDB that has the form, table and how I use it - let me know. Works with MS Network and Novell.

-Eddie



Option Compare Database
Option Explicit
Dim strUserName As String, strNOWcrf As String
'API: Get Login name
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUser_Name() 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
fOSUser_Name = Left$(strUserName, lngLen - 1)
Else
fOSUser_Name = &quot;&quot;
End If
End Function
 
Hi Eddie, I'm not that familiar with Win API programming, can you explain where I should place this codes? Yes, I'd like to have it in mdb as mentioned. Can this code run as a stand alone code, therefore not depending on one application like Access? This question actually relates to my other question where I want to have a reminder function that will get data from Access tables (without having Access running), and then pop up reminder to a specific user in the network LAN who has the related reminder - irrespective which computer in the network he is using. Thanks.

Sandra
 
Cheers Eddie A star for you just what I needed!

Sam

&quot;You couldn't fool your mother on the foolingest day of your life if you had an electrified fooling machine.&quot; - Homer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top