T
Todd K.
I use the following code to get the current user for automation purposes in
my main form:
Option Compare Database
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
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
Unfortunately I am not very experienced with modules/public functions, and I
was wondering how I could make this code public so that I could just
reference fOSUserName() in any of my forms in this database instead of
pasting all of this code in each form I need to use the function in.
my main form:
Option Compare Database
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
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
Unfortunately I am not very experienced with modules/public functions, and I
was wondering how I could make this code public so that I could just
reference fOSUserName() in any of my forms in this database instead of
pasting all of this code in each form I need to use the function in.