fraser_lindsay
Access wannabe
- Local time
- Today, 10:24
- Joined
- Sep 7, 2005
- Messages
- 218
Hi,
I have made a module (fOSUserName) using this code from my searches:
On my welcome screen I have created an unbound text box (txtUserName) and I have set the control source to = fOSUserName()
However, I just get '#Name' displaying in my text box.
I can't see what I'm doing wrong and Google generally keeps giving the same code and no additional explanation on usage.
Can anyone help me out please?
I have made a module (fOSUserName) using this code from my searches:
Code:
'******************** Code Start **************************
' 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
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
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
End Function
'******************** Code End **************************
On my welcome screen I have created an unbound text box (txtUserName) and I have set the control source to = fOSUserName()
However, I just get '#Name' displaying in my text box.
I can't see what I'm doing wrong and Google generally keeps giving the same code and no additional explanation on usage.
Can anyone help me out please?