
Originally Posted by
slave138
Maybe type "Public" before the Function declaration in the module?
If I understood you correctly I tried that with the same error results
here is the Modal code
Code:
Option Compare Database
'******************** 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
Public 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