Any ideas on how to identify current user in Access 2007 file format?
Any ideas on how to identify current user in Access 2007 file format?
Hi,
try the following functionj
-------------------
Function getOSUserName() As String
On Error GoTo Err_getOSUserName
' Geeft de login naam van Windows
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
getOSUserName = Left$(strUserName, lngLen - 1)
Else
getOSUserName = vbNullString
End If
Exit_Err_getOSUserName:
Exit Function
Err_getOSUserName:
Call gsgErrorHandling
Resume Exit_Err_getOSUserName
End Function
------------------------------
grNG
Here's something that will work as is:
http://www.mvps.org/access/api/api0008.htm
Worked like a charm! Thank you very much!
Happy to help!
I have the API saved as a module, but I do not know how to incororate it. Any chance you could help me out with it?
You simply call the function where you want the user name. To put it into a textbox:
Me.TextboxName = fOSUserName()
It is apparent that:
Private Sub Form_Load()
Me.Text0 = fOSUserName()
End Sub
is incorrect.
This is working for me:
Code:Private Sub Form_Load() Me.txtUserID = fOSUserName End Sub